以下代码在两年前可以正常工作。
Xcode 更新后出现“AnyObject 不是 NSArray 的子类型”错误。谁能帮我修一下?
override func viewWillAppear(_ animated: Bool) {
if let storednoteItems : AnyObject = UserDefaults.standard.object(forKey: "noteItems") as AnyObject? {
noteItems = []
for i in 0 ..< storednoteItems.count += 1 {
// the above line getting Anyobject is not a subtype of NSArray error
noteItems.append(storednoteItems[i] as! String)
}
}
}