Tuesday, May 7, 2013

NSDictionary allValues example ios


allValues

Returns a new array containing the dictionary’s values.
- (NSArray *)allValues
Return Value of [NSDictionary allValues]
A new array containing the dictionary’s values, or an empty array if the dictionary has no entries.
Discussion
The order of the values in the array isn’t defined.
Example of [NSDictionary allValues]
myArray = [[NSArray alloc] initWithArray:[myDic allValues]];
Example of [NSDictionary allValues]
NSArray *sortedValues = [[yourDictionary allValues] sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
NSMutableDictionary *orderedDictionary=[[NSMutableDictionary alloc]init];
for(NSString *valor in sortedValues){
    for(NSString *clave in [yourDictionary allKeys]){
        if ([valor isEqualToString:[yourDictionary valueForKey:clave]]) {
            [orderedDictionary setValue:valor forKey:clave];
        }
    }
}