【发布时间】:2015-05-28 14:07:33
【问题描述】:
这是 MyObjCClass.h 中用户名的声明:
@property (nonatomic, assign, readwrite) NSString* username;
这就是我在 MyViewController.swift 中影响它的方式:
// MyObjCObject.username = NSString(string: "homerSimpson") // not accepted by xCode : 'NSString' is not implicitly convertible to 'String'; did you mean to use 'as' to explicitly convert ?
MyObjCObject.username = "homerSimpson"
这就是我在 MyObjCClass.m 中使用属性的方式:
NSLog(_username) // running error happens here
错误:
ECX_BAD_ACCESS : (code=1, address=0x0)
【问题讨论】:
-
为什么不(非原子,强)?
-
你甚至可以在不通过 Swift 的情况下复制它。
标签: objective-c swift nsstring interop