我已经在Swift 4.0中开发了我的应用程序,最近我用10.2更新了Xcode,现在它指出了很多错误,这些错误与以前的版本完全兼容。我不知道如何解决这些问题,我附上了问题专栏和枯萎的问题。
1。“ Notification”类型的值没有成员“ userInfo”(错误名称)
if let image = notification.userInfo?["image"] as? Int {
let indexPath = IndexPath(item: image, section: 0)
objtableview.reloadRows(at: [indexPath], with: .left)
}
let dataDict:[String: String] = ["token": fcmToken]
NotificationCenter.default.post(name: Notification.Name("FCMToken"), object: nil, userInfo: dataDict)
3。“通知”类型的值没有成员“对象”(错误名称)
let reachability = notification.object as! Reachability // ERROR Line
switch reachability.connection {
case .none:
debugPrint("Network became unreachable")
case .wifi:
debugPrint("Network reachable through WiFi")
case .cellular:
debugPrint("Network reachable through Cellular Data")
}
4。类型“通知”没有成员“名称”(错误名称)
NotificationCenter.default.addObserver(self,
selector: #selector(self.reachabilityChanged),
name: Notification.Name.reachabilityChanged,
object: reachability)
public extension Notification.Name { // ERROR LINe
static let reachabilityChanged = Notification.Name("reachabilityChanged") //ERROR Line
}
6。成员'post(name:object :)'的歧义引用
func reachabilityChanged() {
let block = connection != .none ? whenReachable : whenUnreachable
DispatchQueue.main.async { [weak self] in
guard let strongSelf = self else { return }
block?(strongSelf)
strongSelf.notificationCenter.post(name: .reachabilityChanged, object: strongSelf) // ERROR LInE
}
}
请检查此内容,并帮助我解决问题