Reputation: 1242
In my code I have to get the value from NSDictionary but it crashes and the crash issue is,
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<__NSCFString 0x155000fa0> valueForUndefinedKey:]: this class is not key value coding-compliant for the key success.'
Here I show the the code what I am trying.
NSLog(@"finalValNotify is: %@", finalValNotify);
if (finalValNotify) {
int successResult=[[finalValNotify valueForKey:@"success"]intValue]; ====>This line app crashed
if (successResult==1) {
NSLog(@"finalValNotify is: %d", successResult);
}
}
Here I show the printed NSDictionary value:
finalValNotify is: {"multicast_id":5704734283387573862,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1534486056437155%1dbdaa031dbdaa03"}]}
But I don't know the reason for why the crash was occur.
Upvotes: 0
Views: 63
Reputation: 246
If finalValNotify
is your NSDictionary then use as -
int successResult = [finalValNotify[@"success"] intValue];
Upvotes: 0