深さ2レベルのキー価値関係でnsarrayを並べ替える
-
02-10-2019 - |
質問
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のドキュメント(ここ)キーだけでなく、キーパスを受け入れると言います。
所属していません StackOverflow