Check if NSDictionary already has a key or not

suggest change

Objective c:

//this is the dictionary you start with. 
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:@"name1", @"Sam",@"name2", @"Sanju",nil];
//check if the dictionary contains the key you are going to modify.  In this example, @"Sam"
if (dict[@"name1"] != nil) {
    //there is an entry for Key name1       
}
else {
    //There is no entry for name1       
}

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


NSDictionary:
*Check if NSDictionary already has a key or not

Table Of Contents