<div dir="ltr">Nope, that doesn&#39;t work, try it yourself.<div><br></div><div>I tried that, any many more variations, before posting the minimal repro example here.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jul 21, 2016 at 5:46 PM, Jordan Rose <span dir="ltr">&lt;<a href="mailto:jordan_rose@apple.com" target="_blank">jordan_rose@apple.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>I’m a bit late here, but I don’t see why this is necessary. John overrode &#39;encode(_: Int, forKey: String)’ instead of ‘encode(_: Int32, forKey: String)’. Sure, overloading makes this kind of mistake harder to spot, especially when the run-time error comes from Objective-C, but it’s hardly unusual for a Swifty program.</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>Jordan</div></font></span><div><div class="h5"><div><br></div><br><div><blockquote type="cite"><div>On Jul 21, 2016, at 13:06, Tony Parker via swift-users &lt;<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>&gt; wrote:</div><br><div><div style="word-wrap:break-word">FYI:<div><br></div><div><a href="https://github.com/apple/swift/pull/3663" target="_blank">https://github.com/apple/swift/pull/3663</a></div><div><br></div><div>- Tony</div><div><br><div><blockquote type="cite"><div>On Jul 20, 2016, at 12:10 PM, Tony Parker via swift-users &lt;<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>&gt; wrote:</div><br><div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><blockquote type="cite"><div><br>On Jul 20, 2016, at 5:17 AM, John Spurlock &lt;<a href="mailto:john.spurlock@gmail.com" target="_blank">john.spurlock@gmail.com</a>&gt; wrote:</div><br><div><div dir="ltr">1. Since encoding/decoding various types is the principal domain of this type, it seems ok to be overly clear in the method names here.<div><br></div></div></div></blockquote><div><br></div><div>Agreed; I’m trying out a few approaches to see what works best.</div><br><blockquote type="cite"><div><div dir="ltr"><div>2. Is there a way to systematically look for other types that may also have this problem lurking with ints or other similar overload groups?</div></div><div class="gmail_extra"><br></div></div></blockquote><div><br></div><div>I don’t think so. I also know that the importer will happily create ambiguous method names, for example when importing two ObjC methods that are the same except that one has an options argument. The options gets a default value and presto - two methods with the same signature. We only find out when someone tries to use it in other source code.</div><div><br></div><div>- Tony</div><br><blockquote type="cite"><div><div class="gmail_extra"><div class="gmail_quote">On Tue, Jul 19, 2016 at 9:52 PM, Tony Parker<span> </span><span dir="ltr">&lt;<a href="mailto:anthony.parker@apple.com" target="_blank">anthony.parker@apple.com</a>&gt;</span><span> </span>wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="auto"><div><div style="direction:inherit">I thought of the exact same name, but I&#39;m not enthusiastic about the inconsistency this creates with all of the other decode methods on NSCoder. I&#39;m discussing with a few people to decide what to do next. </div><span><font color="#888888"><br>- Tony</font></span></div><div><div><div><br>On Jul 19, 2016, at 6:32 PM, Brent Royal-Gordon &lt;<a href="mailto:brent@architechies.com" target="_blank">brent@architechies.com</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><div>You could just do the one and call it encodeCInt. I think people would understand that it&#39;s different because it&#39;s using a sort-of-foreign type. <br><br><div>-- </div><div>Brent Royal-Gordon</div>Sent from my iPhone</div><div><br>On Jul 19, 2016, at 4:33 PM, Tony Parker &lt;<a href="mailto:anthony.parker@apple.com" target="_blank">anthony.parker@apple.com</a>&gt; wrote:<br><br></div><blockquote type="cite"><div>Hi John,<div><br></div><div>Thanks for filing the bug.</div><div><br></div><div>The root cause of the issue is that the importer would turn the following methods into the same name:</div><div><br></div><div><font face="Menlo">- (void)encodeInt:(int)x forKey:(NSString *)k;</font></div><div><font face="Menlo">- (void)encodeInt32:(uint32_t)x forKey:(NSString *)k;</font></div><div><br></div><div>Plus, there is the added confusion that this method:</div><div><br></div><div><font face="Menlo">- (void)encodeInteger:(NSInteger)x forKey:(NSString *)k;</font></div><div><br></div><div>is imported into Swift like this:</div><div><br></div><div><font face="Menlo">func encode(_ x: Int, forKey k : String)</font></div><div><br></div><div>where, as you can see, “Int” means “NSInteger”, but not the C “int”.</div><div><br></div><div>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><br></div><div><font face="Menlo">func encodeInt(_ x : Int32, forKey k : String)</font></div><div><font face="Menlo">func encodeInt32(_ x : Int32, forKey k : String)</font></div><div><font face="Menlo">func encodeInt64(_ x : Int64, forKey k : String)</font></div><div><font face="Menlo">func encodeInteger(_ x : Int, forKey k : String)</font></div><div><br></div><div>and so on, for all of the encode methods, so they are consistent.</div><div><br></div><div>- Tony</div><div><br><div><blockquote type="cite"><div>On Jul 19, 2016, at 8:20 AM, John Spurlock &lt;<a href="mailto:john.spurlock@gmail.com" target="_blank">john.spurlock@gmail.com</a>&gt; wrote:</div><br><div><div dir="ltr">Ok, filed a new bug for the encodeInt:forKey issue:  <a>rdar://problem/27425997</a><div><br></div><div>Ensured it reproduces in xcode beta 3, swift version 3.0 (swiftlang-800.0.34.6 clang-800.0.33)</div><div><br></div><div>Is there anything I can do in the meantime as a swift-only workaround to fix my custom NSCoder?</div><div><br></div><div>Thanks,</div><div>- john</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 18, 2016 at 10:52 PM, Tony Parker<span> </span><span dir="ltr">&lt;<a href="mailto:anthony.parker@apple.com" target="_blank">anthony.parker@apple.com</a>&gt;</span><span> </span>wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style: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><br>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<span> </span><a href="http://bugreport.apple.com/" rel="noreferrer" target="_blank">bugreport.apple.com</a><span> </span>and let me know the radar number, and we’ll look into it.<br><br>Thanks,<br>- Tony<br><div><div><br>&gt; On Jul 18, 2016, at 6:33 PM, Brent Royal-Gordon &lt;<a href="mailto:brent@architechies.com" target="_blank">brent@architechies.com</a>&gt; wrote:<br>&gt;<br>&gt;&gt; Hi Tony - when I add that attribute, I get an error at compile-time:<br>&gt;&gt; Objective-C method has a different selector from the method it overrides (&#39;encodeInt:forKey:&#39; vs. &#39;encodeInteger:forKey:&#39;)<br>&gt;&gt;<br>&gt;&gt; If I update to encodeInteger:forKey as the fix describes, it compiles, but I&#39;m getting the same original problem at runtime.  i.e. &quot;encodeInt:forKey: only defined for abstract class&quot;<br>&gt;&gt;<br>&gt;&gt; Any other ideas?  See the same thing over there?  You should be able to paste that into a new swift 3 test.<br>&gt;<br>&gt; If you look at the NSCoder documentation, you&#39;ll see 25 methods in the Swift version of the &quot;Encoding General Data&quot; section, and 27 (non-deprecated) in the Objective-C version. `-encodeInt:forKey:` has no Swift equivalent. I&#39;m not sure what the other missing method is.<br>&gt;<br>&gt; I think this is probably a bug or design oversight, and I&#39;d recommend you file a radar against Foundation. If this is a primitive method for NSCoding, it needs to be accessible from Swift.<br>&gt;<br>&gt; --<br>&gt; Brent Royal-Gordon<br>&gt; Architechies<br>&gt;<br><br></div></div></blockquote></div><br></div></div></blockquote></div><br></div></div></blockquote></div></blockquote></div></div></div></blockquote></div><br></div></div></blockquote></div><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">_______________________________________________</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">swift-users mailing list</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><a href="mailto:swift-users@swift.org" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">swift-users@swift.org</a><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><a href="https://lists.swift.org/mailman/listinfo/swift-users" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">https://lists.swift.org/mailman/listinfo/swift-users</a></div></blockquote></div><br></div></div>_______________________________________________<br>swift-users mailing list<br><a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-users" target="_blank">https://lists.swift.org/mailman/listinfo/swift-users</a><br></div></blockquote></div><br></div></div></div></blockquote></div><br></div>