DevWithZachary
DevWithZachary

Reputation: 3675

NSInvalidArgumentException, reason unrecognized selector sent to instance

When processing a json response I a get the below error:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[DADGList setDescription:]: unrecognized selector sent to instance 0x7ae88880'

The class it crashed on:

@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;
}

and the dictonary that is past to listFromDictonary:

Upvotes: 0

Views: 4203

Answers (2)

Alfredo Luco G
Alfredo Luco G

Reputation: 974

If you are using core data maybe you need to implement the following instance:

Mall(entity: NSEntityDescription.entity(forEntityName: "Mall", in: context)!, insertInto: nil)

Where Mall is my entity and context is my view context.

Upvotes: 0

You should rename your description property for something else as this is a field already existing in the iOS echosystem (NSObject if I am not mistaken) and that creates all sort of weird crash like this.

Upvotes: 2

Related Questions