【发布时间】:2016-03-28 21:24:01
【问题描述】:
在 Swift 2.2 之前,以下代码示例编译成功。使用 2.2 它会导致编译器错误:
// launchOptions: [NSObject: AnyObject]?
if let options = launchOptions {
if let notifDict = options[UIApplicationLaunchOptionsRemoteNotificationKey] {
if let phone = notifDict["sender_phone"] {
let predicate = NSPredicate(format: "phoneNumber == %@", phone)
// value of optional type 'String?' not unwrapped; did you mean to use...
}
}
}
当我已经通过 if let 解包到 Dictionary 值时,为什么会出现此错误?
使用 Xcode 7.3 的注意事项
【问题讨论】:
-
什么是
notifDict? -
@dan - 更新问题