<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi John,<div class=""><br class=""></div><div class="">Thanks for filing the bug.</div><div class=""><br class=""></div><div class="">The root cause of the issue is that the importer would turn the following methods into the same name:</div><div class=""><br class=""></div><div class=""><font face="Menlo" class="">- (void)encodeInt:(int)x forKey:(NSString *)k;</font></div><div class=""><font face="Menlo" class="">- (void)encodeInt32:(uint32_t)x forKey:(NSString *)k;</font></div><div class=""><br class=""></div><div class="">Plus, there is the added confusion that this method:</div><div class=""><br class=""></div><div class=""><font face="Menlo" class="">- (void)encodeInteger:(NSInteger)x forKey:(NSString *)k;</font></div><div class=""><br class=""></div><div class="">is imported into Swift like this:</div><div class=""><br class=""></div><div class=""><font face="Menlo" class="">func encode(_ x: Int, forKey k : String)</font></div><div class=""><br class=""></div><div class="">where, as you can see, “Int” means “NSInteger”, but not the C “int”.</div><div class=""><br class=""></div><div class="">I’m not really sure how to resolve this and still allow for subclassing without simply reverting these names back to Swift 2.2 style, so I think that’s probably what I’ll have to do:</div><div class=""><br class=""></div><div class=""><font face="Menlo" class="">func encodeInt(_ x : Int32, forKey k : String)</font></div><div class=""><font face="Menlo" class="">func encodeInt32(_ x : Int32, forKey k : String)</font></div><div class=""><font face="Menlo" class="">func encodeInt64(_ x : Int64, forKey k : String)</font></div><div class=""><font face="Menlo" class="">func encodeInteger(_ x : Int, forKey k : String)</font></div><div class=""><br class=""></div><div class="">and so on, for all of the encode methods, so they are consistent.</div><div class=""><br class=""></div><div class="">- Tony</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jul 19, 2016, at 8:20 AM, John Spurlock <<a href="mailto:john.spurlock@gmail.com" class="">john.spurlock@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Ok, filed a new bug for the encodeInt:forKey issue: <a href="rdar://problem/27425997" class="">rdar://problem/27425997</a><div class=""><br class=""></div><div class="">Ensured it reproduces in xcode beta 3, swift version 3.0 (swiftlang-800.0.34.6 clang-800.0.33)</div><div class=""><br class=""></div><div class="">Is there anything I can do in the meantime as a swift-only workaround to fix my custom NSCoder?</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">- john</div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Mon, Jul 18, 2016 at 10:52 PM, Tony Parker <span dir="ltr" class=""><<a href="mailto:anthony.parker@apple.com" target="_blank" class="">anthony.parker@apple.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">We renamed some of these methods for Swift 3 in an attempt to remove some of the confusion surrounding which of these did what - they were really named for C types and not Swift ones.<br class="">
<br class="">
encodeInt:forKey: and decodeInt:forKey: are the two missing ones, since they were easily confused with the Swift Int type. I think we’ll have to figure out a different approach here. John, please file a bug at <a href="http://bugreport.apple.com/" rel="noreferrer" target="_blank" class="">bugreport.apple.com</a> and let me know the radar number, and we’ll look into it.<br class="">
<br class="">
Thanks,<br class="">
- Tony<br class="">
<div class="HOEnZb"><div class="h5"><br class="">
> On Jul 18, 2016, at 6:33 PM, Brent Royal-Gordon <<a href="mailto:brent@architechies.com" class="">brent@architechies.com</a>> wrote:<br class="">
><br class="">
>> Hi Tony - when I add that attribute, I get an error at compile-time:<br class="">
>> Objective-C method has a different selector from the method it overrides ('encodeInt:forKey:' vs. 'encodeInteger:forKey:')<br class="">
>><br class="">
>> If I update to encodeInteger:forKey as the fix describes, it compiles, but I'm getting the same original problem at runtime. i.e. "encodeInt:forKey: only defined for abstract class"<br class="">
>><br class="">
>> Any other ideas? See the same thing over there? You should be able to paste that into a new swift 3 test.<br class="">
><br class="">
> If you look at the NSCoder documentation, you'll see 25 methods in the Swift version of the "Encoding General Data" section, and 27 (non-deprecated) in the Objective-C version. `-encodeInt:forKey:` has no Swift equivalent. I'm not sure what the other missing method is.<br class="">
><br class="">
> I think this is probably a bug or design oversight, and I'd recommend you file a radar against Foundation. If this is a primitive method for NSCoding, it needs to be accessible from Swift.<br class="">
><br class="">
> --<br class="">
> Brent Royal-Gordon<br class="">
> Architechies<br class="">
><br class="">
<br class="">
</div></div></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></div></body></html>