[英]How to create NSData from a string and an image together and decompile this NSData to a string and an image before
I've got an problem with it,Can you help me! 我有一个问题,你能帮我吗! Thank you so much! 非常感谢! NSString *mystring; NSString * mystring; UIImage *image; UIImage *图片; NSData *data = ... include data of string and image and can decompile to them like before NSData * data = ...包含字符串和图像的数据,可以像以前一样对其进行反编译
You can do in following manner 您可以按照以下方式进行
NSString *aStrImageName = [NSString stringWithFormat:@"splash_ipad.png"];
UIImage *aImg = [UIImage imageNamed:aStrImageName];
NSDictionary *aDictData = [NSDictionary dictionaryWithObjectsAndKeys:aStrImageName,@"ImageName",aImg,@"Image", nil];
NSData *aObjData = [NSKeyedArchiver archivedDataWithRootObject:aDictData];
NSDictionary *aDictBack = (NSDictionary*) [NSKeyedUnarchiver unarchiveObjectWithData:aObjData];
NSString *aStrImageNameBack = [aDictBack valueForKey:@"ImageName"];
UIImage *aImgBack = [aDictBack objectForKey:@"Image"];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.