views:

35

answers:

1

In .NET, I can use Encoding.UTF8.GetString(string str) or any other flavor of Encoding, to get the string representation of a byte array. Does Cocoa contain similar functionality out-of-the-box, or do I need to write some stuff to make the conversions myself?

+7  A: 

You use initWithData:encoding. E.g.:

[[NSString alloc] initWithData: dataObj encoding: NSUTF8StringEncoding]
Matthew Flaschen
Thanks--very simple, very elegant!
Brian Warshaw