<div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif">I don't think this is the good place for your question. Maybe stackoverflow or apple developer forum is more suitable.</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">Did you added the header filename of the category to your bridge file? Also, is there the method name in the header file as well? You know, sometimes people wouldn't include the method name in the header but implementing it directly in the .m file.</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">Zhaoxin</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, May 24, 2017 at 4:10 AM, Russell Finn via swift-users <span dir="ltr"><<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><p style="margin:0px;font-size:12px;line-height:normal;font-family:Helvetica">I'm having an issue with an NSDictionary that is passing through Swift code and back to Objective-C losing access to a method implemented by a category on NSDictionary. There is clearly some subtlety about bridged dictionaries that I'm missing, and I'd appreciate any clarification that the list can provide.</p><p style="margin:0px;font-size:12px;line-height:normal;font-family:Helvetica"><br></p><p style="margin:0px;font-size:12px;line-height:normal;font-family:Helvetica">Specifically: I have a Swift 3 application that uses some legacy Objective-C classes. One of these classes relies on a category on NSDictionary that implements a method called `-boolValueForKey:`. </p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Helvetica;min-height:14px"><br></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Helvetica">In the main application, the Swift code calls a method on a remote object proxy that returns an NSDictionary, which get bridged back to a Swift dictionary (`[AnyHashable: Any]`). This bridged dictionary is passed to a method on the legacy Objective-C class that calls the `-boolValueForKey:` method from the category. At this point, a runtime exception occurs that says the dictionary object (which at this point is a `_SwiftDeferredNSDictionary`, according to the debugger) doesn’t recognize the selector `-boolValueForKey:`.</p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Helvetica;min-height:14px"><br></p>
<p style="margin:0px;font-size:12px;line-height:normal;font-family:Helvetica">I can work around the issue in my code by modifying the legacy Objective-C class and inlining the implementation of `-boolValueForKey:` — but is there a better general approach?</p><div><br></div><div>Thanks — Russell</div><div><br></div></div>
<br>______________________________<wbr>_________________<br>
swift-users mailing list<br>
<a href="mailto:swift-users@swift.org">swift-users@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-users</a><br>
<br></blockquote></div><br></div>