iPhone:将 NSMutableArray 转换为 NSData 并存储 &已检索问题
我面临一个问题,即将 NSMutableArray
转换为 NSData
并存储 &将该数组检索到 rootviewcontroller 中,所以请给我想法。这是我正在使用的代码:
appDelegate = (FindNearMeAppDelegate *)[[UIApplication sharedApplication]delegate];
appDelegate.isCategoryCell = TRUE;
appDelegate.isButton = NO;
NSString *categoryStr = categoryName.text;
NSLog(@"Category Name:--->%@",categoryStr);
appDelegate.categoryData = [NSMutableDictionary dictionaryWithObjectsAndKeys:
categoryStr, @"name",image ,@"image", nil];
[appDelegate.categories addObject:appDelegate.categoryData];
NSLog(@"Category Data:--->%@",appDelegate.categories);
我在 appdelegate 中初始化 nsmutablearray (appDelegate.categories) 和 nsmutabledictionary。
提前致谢。
I am facing a problem, that is to convert NSMutableArray
into NSData
and stored & retrieved that array into rootviewcontroller
so please give me idea. Here is the code I'm working with:
appDelegate = (FindNearMeAppDelegate *)[[UIApplication sharedApplication]delegate];
appDelegate.isCategoryCell = TRUE;
appDelegate.isButton = NO;
NSString *categoryStr = categoryName.text;
NSLog(@"Category Name:--->%@",categoryStr);
appDelegate.categoryData = [NSMutableDictionary dictionaryWithObjectsAndKeys:
categoryStr, @"name",image ,@"image", nil];
[appDelegate.categories addObject:appDelegate.categoryData];
NSLog(@"Category Data:--->%@",appDelegate.categories);
I am initialize nsmutablearray (appDelegate.categories) and nsmutabledictionary in appdelegate.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我了解,您想要保存图像并检索它们。您可以使用以下两种方法之一将图像转换为
NSData
:UIImagePNGRepresentation
或UIImageJPEGRepresentation
,具体取决于图像的类型。然后您可以保存这些数据 -From what I understand, you want to save your images and retrieve them. You can convert your image to
NSData
using one of the 2 methods,UIImagePNGRepresentation
orUIImageJPEGRepresentation
depending on the type of the image. You can then save this data-