1 //NSData转换为UIImage 2 NSData *imageData = [NSData dataWithContentsOfFile: imagePath]; 3 UIImage *image = [UIImage imageWithData: imageData]; 4 5 //UIImage转换为NSData 6 NSData *imageData = UIImagePNGRepresentation(aimae);
1. 字符串转Data NSString * str =@"str"; NSData *data =[str dataUsingEncoding:NSUTF8StringEncoding]; 2.NSData 转NSString NSString * str =[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; 3.data 转char NSData *data; char * haha=[data bytes]; 4. char 转data byte * byteData = malloc(sizeof(byte)*16); NSData *content=[NSData dataWithBytes:byteData length:16];
纯属记录!