views:

40

answers:

2

So I have this:

  NSData *charlieSendData = [[charlieImputText stringValue] dataUsingEncoding:NSUTF8StringEncoding];

I know how to convert NSStrings to data but how I convert data back to an NSString?

Elijah

+3  A: 

You can use NSString's -initWithData:encoding: initializer method.

NSData *charlieSendData = [[charlieImputText stringValue] dataUsingEncoding:NSUTF8StringEncoding]
NSString *charlieSendString = [[NSString alloc] initWithData:charlieSendData encoding:NSUTF8StringEncoding];
Jacob Relkin
+3  A: 

Use NSString's initWithData method:

NSString *someString = [[NSString alloc] initWithData:charlieSendData encoding:NSUTF8StringEncoding];

That should do it.

codykrieger