質問

nsdictionaryであるuilocalnotificationのuserinfoプロパティ内のキーに従ってソートする必要があるuilocalnotificationオブジェクトのnsarrayがあります。私は、nsdictionaryの配列内の鍵など、1レベルの深い値でnsarrayを並べ替える方法を知っていますが、2つのレベルの深さは私が失われています。このようなことをしたいのは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];
役に立ちましたか?

解決

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

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top