• 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: Init String with bytes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Init String with bytes


  • Subject: Re: Init String with bytes
  • From: Charles Srstka <email@hidden>
  • Date: Fri, 31 Jul 2015 15:47:01 -0500

> On Jul 31, 2015, at 2:51 PM, Jens Alfke <email@hidden> wrote:
>
> Your code should work if you change String(…) to NSString(…).

However, there’s no need to bother getting the bytes and length from the NSData, since there’s an initializer that takes just an NSData:

if let name = NSString(data: dataValue, encoding: NSUTF8StringEncoding) as? String {
	// do something with name
}

Charles

_______________________________________________

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


References: 
 >Init String with bytes (From: "Jan E. Schotsman" <email@hidden>)
 >Re: Init String with bytes (From: Jens Alfke <email@hidden>)

  • Prev by Date: Re: FSFileManager strange behaviour on OS X
  • Next by Date: Swift NSOutlineView "Illegal NSOutlineView data source"
  • Previous by thread: Re: Init String with bytes
  • Next by thread: Reusable Detail View Controller for UISplitViewController?
  • Index(es):
    • Date
    • Thread