How do I convert an NSString value to NSData?

anish picture anish · May 23, 2009 · Viewed 440.2k times · Source

How do I convert an NSString value to NSData?

Answer

flitzwald picture flitzwald · May 23, 2009
NSString* str = @"teststring";
NSData* data = [str dataUsingEncoding:NSUTF8StringEncoding];