[swift-users] 'Error' is ambiguous for type lookup in this context

Zhao Xin owenzx at gmail.com
Wed Sep 7 23:40:22 CDT 2016


Thank you for all your replies, Shawn.

Zhaoxin

On Thu, Sep 8, 2016 at 12:22 PM, Shawn Erickson <shawnce at gmail.com> wrote:

> You are implementing function defined in the WCSessionDelegate so that
> your AppDelegate can be called by WCSession as things happen. It calls your
> implementation and supplies it with an error is one exists (e.g. an error
> happened).
>
> It doesn't make sense for this function (the one you implement) to throw
> since you aren't returning an error to the caller (WCSession) but instead
> potentially getting an error from the caller (WCSession).
>
> -Shawn
>
> On Wed, Sep 7, 2016 at 8:53 PM Zhao Xin <owenzx at gmail.com> wrote:
>
>> I also have a question on this API
>> ‚Äč`func session(_ session: WCSession, activationDidCompleteWith
>> activationState: WCSessionActivationState, error: Error?)`. Why did it use
>> `throws`? The other APIs, which use NSError in Objective-C, change to
>> throws in Swift counterpart.
>>
>> Zhaoxin
>>
>> On Thu, Sep 8, 2016 at 10:52 AM, Shawn Erickson <shawnce at gmail.com>
>> wrote:
>>
>>> For one RealmSwift should likely consider changing their enum cases to
>>> use lowerCamelCase like Swift 3 did. Also at some point it should consider
>>> the changes to NSError / Swift.Error bridging.
>>>
>>> -Shawn
>>>
>>> On Wed, Sep 7, 2016 at 7:18 PM Zhao Xin via swift-users <
>>> swift-users at swift.org> wrote:
>>>
>>>> When I use RealmSwift in my project, I got an alert " 'Error' is
>>>> ambiguous for type lookup in this context".
>>>>
>>>> import UIKit
>>>>
>>>> import UserNotifications
>>>>
>>>> import WatchConnectivity
>>>>
>>>> import RealmSwift
>>>>
>>>>
>>>> extension AppDelegate:WCSessionDelegate {
>>>>
>>>>     func session(_ session: WCSession, activationDidCompleteWith
>>>> activationState: WCSessionActivationState, error: Error?) {
>>>>
>>>>
>>>>     }
>>>>  }
>>>>
>>>>
>>>> I think the reason is that in Swift, Error is a protocol. And in
>>>> RealmSwift, there is a `case Error(NSError)` in `public enum
>>>> RealmCollectionChange<T>`.
>>>>
>>>>
>>>> I managed to eliminate the alert buy change `Error?` to `Swift.Error?`.
>>>> Are there any other ways to fix this?
>>>>
>>>>
>>>> Zhaoxin
>>>> _______________________________________________
>>>> swift-users mailing list
>>>> swift-users at swift.org
>>>> https://lists.swift.org/mailman/listinfo/swift-users
>>>>
>>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160908/a7eebf98/attachment.html>


More information about the swift-users mailing list