class ABC{
@NSManaged var liked: Bool
.....
}
在其他班级
class xyz{
func afunc(){
let item = ABC()
if item.liked == true{ // getting crash on this line
}}}
[错误]:输入信息TC,N,D尚不支持
*由于未捕获的异常'NSInvalidArgumentException'终止应用程序,原因:' - [...]:无法识别的选择器发送到实例0x15d78310' * 首先抛出调用堆栈:
我只是访问我在类中创建的值 它在一台设备上工作正常(ios版本8.1和8.3)并在另一台设备上抛出错误(ios版本8.4)。
答案 0 :(得分:0)
我认为您已创建0
。那么它应该如下:
swift class
答案 1 :(得分:0)
class ClassA: NSObject {
var liked:Bool
override init() {
liked = true
}
}
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
execute();
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func execute(){
let item = ClassA();
if item.liked==true{
print(item.liked)
}
}
}