在处理 json 响应时,出现以下错误:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[DADGList setDescription:]: unrecognized selector sent to instance 0x7ae88880'
它崩溃的类:
@implementation DADGList
-(id)copy
{
DADGList *list = [[DADGList alloc] init];
list.identifier = self.identifier;
list.name = [self.name copy];
list.description = [self.description copy];
list.created = [self.created copy];
list.itemCount = self.itemCount;
list.shareLink = [self.shareLink copy];
return list;
}
+(DADGList *)listFromDictonary:(NSDictionary *)dictonary
{
DADGList *list = [[DADGList alloc] init];
NSLog( @"%@", dictonary );
list.identifier = [[dictonary objectForKey:@"list_id"] integerValue];
list.itemCount = [[dictonary objectForKey:@"list_items_count"] integerValue];
list.name = [NSString stringWithString:[dictonary objectForKey:@"list_name"]];
list.description = [NSString stringWithString:[dictonary objectForKey:@"list_description"]];
list.created = [[NSDate alloc] initWithTimeIntervalSince1970:[[dictonary objectForKey:@"list_created"] doubleValue]];
list.shareLink = [NSString stringWithString:[dictonary objectForKey:@"list_share_url"]];
return list;
}
和 listFromDictonary 过去的字典:
最佳答案
您应该将您的 description
属性重命名为其他内容,因为这是一个已经存在于 iOS 回声系统中的字段(如果我没记错的话是 NSObject)并且会造成像这样的各种奇怪的崩溃。
关于ios - NSInvalidArgumentException,将无法识别的选择器发送到实例的原因,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30358877/