NSString cString is Deprecated. What is the alternative?
- Get the raw bytes from the string.
- Get the length of those bytes in the UTF8 encoding.
- Create the
NSData
object using the+dataWithBytes:length:
method.
const char *rawBytes = [testXMLDataString UTF8String];const NSUInteger length = [testXMLDataString lengthOfBytesUsingEncoding:NSUTF8StringEncoding];NSAssert(length > 0, @"Couldn't convert to UTF-8");NSMutableData *testXMLData = [NSMutableData dataWithBytes:rawBytes length:length];[webData setData:testXMLData];