我将 a 存储UIImage
在 aNSDictionary
中,然后NSDictionary
在应用程序的另一个位置传递。gridImages 是一个NSMutableArray
NSDictionary *pageDict = [pageArray objectAtIndex:0];
UIImage *pageImage = [pageDict objectForKey:@"image"];
[gridImages addObject:pageImage];
pagedict 返回
{
class = is;
image = "<UIImage: 0x14e20e10>";
name = kaka;
page = 64;
}
大概是我做的
UIImage *pageImage = [pageDict objectForKey:@"image"];
但是,当我尝试将该 UIImage 添加到数组时,出现此错误:
-[UIImage stringByDeletingPathExtension]: unrecognized selector sent to instance 0x14e20e10
知道发生了什么吗?
编辑:
对于NSDictionary
,我尝试将其存储UIImage
为NSData
:
NSData *imageData = UIImagePNGRepresentation(textbookImage);
[pageDict setObject:imageData forKey:@"image"];
[pageDict setObject:textbookName forKey:@"name"];
[pageDict setObject:page forKey:@"page"];
[pageDict setObject:nameOfClass forKey:@"class"];
并像这样解析它:
NSData *imageData = [pageDict objectForKey:@"image"];
UIImage *pageImage = [UIImage imageWithData:imageData];
但它仍然返回相同的错误