Re: Init String with bytes
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