Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我刚刚升级到 Swift 2.0 和 Xcode 7 Beta,我收到了错误:
无法将“String”类型的值分配给“String”类型的值
写作时:
var string = (change[NSKeyValueChangeNewKey]) as! String?
我认为这as! String?部分是问题所在。
as! String?
你可能应该这样做:
if let string = change[NSKeyValueChangeNewKey] as? String { // Do something with `string` }