> Le 20 févr. 2016 à 07:28, Quincey Morris 
> <quinceymor...@rivergatesoftware.com> a écrit :
> 
> On Feb 19, 2016, at 22:14 , Gerriet M. Denkmann <gerr...@mdenkmann.de> wrote:
>> 
>> Is there (yet) a Swift version of ‘[NSString stringWithFormat: “%08lx”, 
>> (someCast) someValue]’ ?
> 
> No, and yes, and no, and yes.
> 
> There is currently AFAIK no such native formatting syntax in Swift print 
> statements, so “no”.
> 
> But you can of course use ‘String (format: “%08lx”, someCast (someValue))’. 
> This isn’t actually cheating, because Swift has its own implementation of the 
> entire NSString API. There’s no bridging to NSString objects involved in 
> these functions, so “yes”.
> 
> But you can’t *use* this API in Swift unless you import Foundation. Without 
> the import, Swift will pretend it doesn’t have those String APIs, though it 
> really does, so “no”.
> 
> But starting with Swift 3, later this year, Foundation will migrate natively 
> into Swift — for all supported Swift platforms, such as Linux — so I assume 
> there will be some kind of native String formatting syntax, so “yes”, though 
> whether it will use the same format strings as Cocoa, I don’t know.


Even if swift is planning to provide a Foundation framework, one of the strong 
requirement is that it must be source compatible with the Apple Foundation, as 
that is the one that will be used on Apple platforms. So if it does not behave 
like NSString, it should be considered a bug.


_______________________________________________

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

Reply via email to