xcode8 beta 'Error' is ambiguous for type lookup in this context

拜拜、爱过 提交于 2019-12-08 17:22:51

问题


According to this article , I need to specify the module to lookup object type , but below function is call from apple api , should I need to wait until Xcode8 really release ? or am I miss anything ?

function in AppDelegate.swift

Import section


回答1:


The Solution is to just type Swift.Error instead of Error.

The issue occurs when one of your modules has its own Error Type...:/

For example:

func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Swift.Error) {}

I hope this works for you :)




回答2:


The type Error is declared in two imported modules. You have to specify the module from which to use the type. Use Swift.Method instead of Method.

Tip: If you are using the type often, you can create a type alias in your module (application):

typealias Error = Swift.Error

That way you will not need to prefix the type with Swift. any more.



来源:https://stackoverflow.com/questions/39394514/xcode8-beta-error-is-ambiguous-for-type-lookup-in-this-context

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!