views:

131

answers:

1

I have an NSArray of UILocalNotification objects that I need to sort according to a key within the UILocalNotification's userInfo property, which is an NSDictionary. I know how to sort NSArrays by a value that is one level deep, e.g., a key within an array of NSDictionaries, but two levels deep I'm lost. I want to do something like this is psuedo-code:

NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"userInfo.personName" ascending:YES]; 
//the personName key within the userInfo NSDictionary property of a given UILocalNotification
NSArray *sortDescriptors = [[[NSArray alloc] initWithObjects:&sortDescriptor count:1] autorelease];
NSMutableArray *sortedArray = [[[NSMutableArray alloc] initWithArray:[[UIApplication sharedApplication] scheduledLocalNotifications]] autorelease];
[sortedArray sortUsingDescriptors:sortDescriptors];
+1  A: 

Did you try your code? Apple's document (here) says it accepts key paths, not just keys.

Yuji
I thought I had remembered that dot syntax from somewhere!
Cirrostratus