allKeysForObject:
Returns a new array containing the keys corresponding to all occurrences of a given object in the dictionary.
- (NSArray *)allKeysForObject:(id)anObject
Parameters
- anObject
- The value to look for in the dictionary.
Return Value of [NSDictionary allKeysForObject]
A new array containing the keys corresponding to all occurrences of anObject in the dictionary. If no object matching anObject is found, returns an empty array.
Discussion
Each object in the dictionary is sent an
isEqual:
message to determine if it’s equal toanObject.
Example of [NSDictionary allKeysForObject]
NSString* playerId = @"player_id";
for(){
NSMutableArray *current_row = [NSMutableArray arrayWithObjects: playerId,...];
...
}
NSArray *newArray = [expense_ArrContents allKeysForObject :playerId];
Example of [NSDictionary allKeysForObject]
NSString *knownObject = @"the object";
NSArray *temp = [dict allKeysForObject :knownObject];
NSString *key = [temp objectAtIndex:0];
//"key" is now equal to the key of the object you were looking for