你如何处理Swift 3.0中的错误代码?

时间:2016-09-27 09:33:49

标签: ios swift swift3 nserror

由于NSError已成为Swift 3.0中的Error,您如何处理错误代码?例如:

func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
        if error.code == 3010 {
            print("Push notifications are not supported in the iOS Simulator.")
        } else {
            print("application:didFailToRegisterForRemoteNotificationsWithError: %@", error)
        }
    }

给出消息Value of type Error has no member code。我应该把它投到NSError?

0 个答案:

没有答案