ios - NSInvalidArgumentException,将无法识别的选择器发送到实例的原因

标签 ios objective-c unrecognized-selector

在处理 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/

相关文章:

ios - 如果一个隐藏在 swift 3 中,如何调整用其他 View /uitextfield 填充 uitextfield 的空间?

iphone - 导航栏隐藏状态栏

iphone - 在 iOS 应用程序中显示服务器端内容 - 需要的方法

iphone - 找不到协议(protocol)声明

ios - 当用户单击通知警报并且应用程序未运行时如何接收数据消息

objective-c - UIButton 就像 UIActionSheet 中的那样

objective-c - 检测 NSColorWell 的更改选择

ios - 尝试在我的应用程序中打开苹果 map 应用程序时发送到实例的无法识别的选择器

objective-c - 尝试关闭键盘时出现 "unrecognized selector"错误

ios - 尝试通过快速桥接头调用扩展方法时发送到实例的无法识别的选择器