Hello everyone i have one problem in parsing a dictionary here is dictionary
{
"@id" = 10;
activityLocation = "";
activityPriority = 1;
actualEndDate = "<null>";
actualStartDate = "<null>";
children = (
);
}
i am getting this responce in json and when i tried to parse this dictionay and tried to get the @id value from dictionary it gives me error like
[<__NSCFDictionary 0x7b07d370> valueForUndefinedKey:]: this class is not key value coding-compliant for the key id.
I have tried to get @id value like below code
NSString *id_user = [dictResponce valueForKey:@"@id"];
int user_id = [id_user intValue];
Please suggest me where i am going wrong
You cannot use
valueForKey:
method for getting corresponding object from an NSDictionary, it should beNSString *id_user = [dictResponce objectForKey:@"@id"];
.For getting ann object with
valueForKey:
, it should be anNSMutableDictionary
EDIT:
Actual problem is not the
valueForKey:
method, The bug is in the key, you cannot use a leading@
in avalueForKey:
method, because@
is used for collection operators like@sum
,@count
etc(its invalueForKeyPath:
method, I don't know why its trowing exception invalueForKey:
method also) Ref:https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/KeyValueCoding/Articles/CollectionOperators.html#//apple_ref/doc/uid/20002176-BAJEAIEE