我正在尝试将 NSMutableArray* 复制到 NSArray* 中,但它不起作用并且会生成[__NSCFString superview]: unrecognized selector sent to instance error 。这是代码:
//where gc is a NSDictionary*, recentKey is a NSString*, and _objects is a NSArray*
//gc is an singleton is used to save chache data, with NSKeyedUnarchiver class
//_objects is used to reload the UITableView's data
NSArray *savedNews = [[NSArray alloc] initWithArray:[gc objectForKey:recentkey]];
//this not works...why??
_objects = [[NSArray alloc] initWithArray:savedNews];
解析度:
是的,正如赫尔曼所说,错误是外部的。savedNews 数组使用带有 NSEncoding 的类,但出现错误:
- (void)encodeWithCoder:(NSCoder *)encoder {
//...where element was NSString* and not "UIImageView"
// element should be imgView
if (imgView) [encoder encodeObject:element forKey:@"imgView"];
}
谢谢大家。