1 NSString * str = @"hello, world!"; 2 NSData * data = [str dataUsingEncoding:NSUTF8StringEncoding]; //NSString转换成NSData类型 3 NSLog(@"%s", data.bytes); 4 NSString * newStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; 5 NSLog(@"%@", newStr);