How do I convert an NSString value to NSData?
如何将NSString
值转换为NSData
?
NSString* str = @"teststring";
NSData* data = [str dataUsingEncoding:NSUTF8StringEncoding];
NSString *str = @"helowrld";
// This converts the string to an NSData object
NSData *data = [str dataUsingEncoding:NSUTF8StringEncoding];
你可以参考这个链接
Converting NSString
like so will force a trailing