0

NSDictionary である UILocalNotification の userInfo プロパティ内のキーに従って並べ替える必要がある UILocalNotification オブジェクトの NSArray があります。NSArrays を 1 レベルの深さの値 (NSDictionaries の配列内のキーなど) で並べ替える方法は知っていますが、2 レベルの深さではわかりません。このようなことをしたいのは疑似コードです:

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];
4

1 に答える 1

1

コードを試しましたか?Apple のドキュメント ( here ) には、キーだけでなくキー パスを受け入れると書かれています。

于 2010-07-03T02:54:57.997 に答える