On Aug 1, 2012, at 7:00 AM, Erik Stainsby wrote: > Hi Mark, > > So I have a dictionary like so: > > NSDictionary * countries = [NSDictionary dictionaryWithObjects:[NSArray > arrayWithObjects:@"Australia",@"Canada",@"United Kingdom",@"United > States",nil] forKeys:[NSArray arrayWithObjects:@"au",@"ca",@"uk",@"us",nil]]; > > I want to present them alphabetically as menuItems in an NSPopUpButton. I > grab the list of keys: > > NSMutableArray * sortkeys = [NSMutableArray arrayWithArray:[countries > allKeys]]; > > What I have come up with is this: > > [sortkeys sortUsingComparator:^NSComparisonResult(id obj1, id obj2) { > return [(NSString*)obj1 compare:(NSString*)obj2 ]; > } ]; > > Is this a sane approach ? Seems a bit fussy to have to spec the cast like > this. Or is this just the what-is of this kind of functionality?
Why not just use an NSDictionaryController and bind sortDescriptors? Keary Suska Esoteritech, Inc. "Demystifying technology for your home or business" _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com