Question

J'ai un NSArray de UILocalNotification objets que je dois trier selon une clé au sein de la propriété userInfo du UILocalNotification, qui est un NSDictionary. Je sais comment trier NSArrays par une valeur qui est un niveau de profondeur, par exemple, une clé dans un tableau de NSDictionaries, mais deux niveaux de profondeur, je suis perdu. Je veux faire quelque chose comme ceci est pseudo-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];
Était-ce utile?

La solution

Avez-vous essayé votre code? Le document d'Apple ( ici ) indique qu'il accepte les chemins clés, pas seulement les clés.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top