How to pass a NSDictionary with postNotificationName:object:

The first NSLog works fine displaying the contents of the dictionary. The second log throws the following exception… The program tries to trick you, it just looks like it is your dictionary because your dictionary is inside the notification. From the exception you can see that your object actually is from a class named NSConcreteNotification. … Read more

Getting NSDictionary keys sorted by their respective values

The NSDictionary Method keysSortedByValueUsingComparator: should do the trick. You just need a method returning an NSComparisonResult that compares the object’s values. Your Dictionary is NSMutableDictionary * myDict; And your Array is NSArray *myArray; myArray = [myDict keysSortedByValueUsingComparator: ^(id obj1, id obj2) { if ([obj1 integerValue] > [obj2 integerValue]) { return (NSComparisonResult)NSOrderedDescending; } if ([obj1 integerValue] … Read more

Convert NSArray to NSDictionary

Try this magic: NSDictionary *dict = [NSDictionary dictionaryWithObjects:records forKeys:[records valueForKey:@”intField”]]; FYI this is possible because of this built-in feature: @interface NSArray(NSKeyValueCoding) /* Return an array containing the results of invoking -valueForKey: on each of the receiver’s elements. The returned array will contain NSNull elements for each instance of -valueForKey: returning nil. */ – (id)valueForKey:(NSString *)key;