• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Why is NSString.UTF8String unavailable in Swift?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why is NSString.UTF8String unavailable in Swift?


  • Subject: Re: Why is NSString.UTF8String unavailable in Swift?
  • From: Jens Alfke <email@hidden>
  • Date: Sat, 21 Mar 2015 16:41:37 -0700

> On Mar 21, 2015, at 2:13 PM, Quincey Morris <email@hidden> wrote:
>
> Well, “String” is not “NSString”.

Sure, but it’s bridged with NSString. The “Using Swift With Cocoa” book says: “Swift automatically bridges between the String type and the NSString class. This means that anywhere you use an NSString object, you can use a Swift String type instead  … you should almost never need to use the NSString class directly in your own code.”

> 	var str = "Hello, playground” as NSString
> 	str.cStringUsingEncoding(NSUTF8StringEncoding) // OK
> 	str.UTF8String  // OK

-cStringUsingEncoding: and several other NSString methods I’ve tried work without the “as NSString” trick; what’s special about “UTF8String”?

—Jens
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Why is NSString.UTF8String unavailable in Swift?
      • From: Kevin Meaney <email@hidden>
    • Re: Why is NSString.UTF8String unavailable in Swift?
      • From: Quincey Morris <email@hidden>
References: 
 >Why is NSString.UTF8String unavailable in Swift? (From: Jens Alfke <email@hidden>)
 >Re: Why is NSString.UTF8String unavailable in Swift? (From: Quincey Morris <email@hidden>)

  • Prev by Date: Re: Why is NSString.UTF8String unavailable in Swift?
  • Next by Date: Re: Why is NSString.UTF8String unavailable in Swift?
  • Previous by thread: Re: Why is NSString.UTF8String unavailable in Swift?
  • Next by thread: Re: Why is NSString.UTF8String unavailable in Swift?
  • Index(es):
    • Date
    • Thread