On Jul 7, 2015, at 2:47 AM, Rick Mann <rm...@latencyzero.com> wrote: > > >> On Jul 7, 2015, at 00:46 , Charles Srstka <cocoa...@charlessoft.com> wrote: >> >> You don’t have an NSString. You have a String. It works differently. > > Well, they're toll-free bridged, and substringToIndex() is a method on > NSString (or so I thought). Anyway, it turns out to be an error in the > documentation, so now I understand.
They are *not* toll-free bridged. When you cast one to the other, it actually does a conversion. The documentation is not incorrect; the method on NSString *does* take an Int. If you try it on strings that are actually typed as NSString, you’ll see that they take an Int: import Foundation let str = "foobar" as NSString let str2 = str.substringFromIndex(3) This results in str2 being “bar”. Swift Strings, however, follow different rules, in order to be safe about cases where a character in a string takes up more than one UTF-16 code unit. Charles _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com