NSDictionary *dic = @{@"obj1", @"key1", @"obj2", @"key2"};
NSArray *keys = [dic allKeys];
keys = [keys sortedArrayUsingComparator:^(id key1,id key2){
return [key1 compare:key2];
}]
for (NSString *key in keys)
{
NSLog(@"key = %@ AND obj = %@",key,[dic objectForKey:key]);
} |
|