处理json响应时,我得到以下错误:
***因未捕获的异常终止应用' NSInvalidArgumentException',原因:' - [DADGList setDescription:]: 无法识别的选择器发送到实例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过去的dictonary:
答案 0 :(得分:2)
您应该将您的description
属性重命名为其他内容,因为这是iOS回声系统中已存在的字段(NSObject,如果我没有记错的话)并且会产生类似这种奇怪的崩溃。
答案 1 :(得分:0)
如果您使用的是 core data
,您可能需要实现以下实例:
Mall(entity: NSEntityDescription.entity(forEntityName: "Mall", in: context)!, insertInto: nil)
其中 Mall
是我的实体,context
是我的视图上下文。