<div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif">When I use RealmSwift in my project, I got an alert &quot; &#39;Error&#39; is ambiguous for type lookup in this context&quot;.</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default"><p style="font-family:menlo;margin:0px;font-size:11px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(187,44,162)">import</span><span style="font-variant-ligatures:no-common-ligatures"> UIKit</span></p>
<p style="font-family:menlo;margin:0px;font-size:11px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(187,44,162)">import</span><span style="font-variant-ligatures:no-common-ligatures"> UserNotifications</span></p>
<p style="font-family:menlo;margin:0px;font-size:11px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(187,44,162)">import</span><span style="font-variant-ligatures:no-common-ligatures"> WatchConnectivity</span></p>
<p style="font-family:menlo;margin:0px;font-size:11px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(187,44,162)">import</span><span style="font-variant-ligatures:no-common-ligatures"> RealmSwift</span></p><p style="font-family:menlo;margin:0px;font-size:11px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures"><br></span></p><p style="font-family:menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(112,61,170)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(187,44,162)">extension</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">AppDelegate</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">:</span><span style="font-variant-ligatures:no-common-ligatures">WCSessionDelegate</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)"> {</span></p><p style="font-family:menlo;margin:0px;font-size:11px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">    </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(187,44,162)">func</span><span style="font-variant-ligatures:no-common-ligatures"> session(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(187,44,162)">_</span><span style="font-variant-ligatures:no-common-ligatures"> session: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)">WCSession</span><span style="font-variant-ligatures:no-common-ligatures">, activationDidCompleteWith activationState: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)">WCSessionActivationState</span><span style="font-variant-ligatures:no-common-ligatures">, error: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)">Error</span><span style="font-variant-ligatures:no-common-ligatures">?) { </span></p><p style="font-family:menlo;margin:0px;font-size:11px;line-height:normal"><br></p><p style="font-family:menlo;margin:0px;font-size:11px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">





</span></p><p style="font-family:menlo;margin:0px;font-size:11px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">    }</span></p><div style="font-family:georgia,serif"><span style="font-family:menlo;font-size:11px"> }</span><br></div><p style="font-family:menlo;margin:0px;font-size:11px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures"><br></span></p><p style="margin:0px;line-height:normal"><font color="#000000" face="georgia, serif"><span style="font-variant-ligatures:no-common-ligatures">I think the reason is that in Swift, Error is a protocol. And in RealmSwift, there is a `</span>case Error(NSError)` in `public enum RealmCollectionChange&lt;T&gt;`.</font></p><p style="margin:0px;line-height:normal"><font face="georgia, serif" color="#000000"><span style="font-variant-ligatures:no-common-ligatures"><br></span></font></p><p style="margin:0px;line-height:normal"><font face="georgia, serif" color="#000000"><span style="font-variant-ligatures:no-common-ligatures">I managed to eliminate the alert buy change `<span style="font-variant-ligatures:no-common-ligatures">Error</span><span style="font-variant-ligatures:no-common-ligatures">?</span>` to `</span><span style="font-variant-ligatures:no-common-ligatures">Swift</span><span style="font-variant-ligatures:no-common-ligatures">.</span><span style="font-variant-ligatures:no-common-ligatures">Error</span><span style="font-variant-ligatures:no-common-ligatures">?`. Are there any other ways to fix this?</span></font></p><p style="margin:0px;line-height:normal"><font face="georgia, serif" color="#000000"><span style="font-variant-ligatures:no-common-ligatures"><br></span></font></p><p style="margin:0px;line-height:normal"><font face="georgia, serif" color="#000000"><span style="font-variant-ligatures:no-common-ligatures">Zhaoxin</span></font></p></div></div>