代码之家  ›  专栏  ›  技术社区  ›  james_womack

按2个层次的键值关系对NSarray进行排序

  •  0
  • james_womack  · 技术社区  · 16 年前

    我有一组uilocalnotification对象,需要根据uilocalnotification的userinfo属性(nsdictionary)中的键进行排序。我知道如何按一个级别深的值对nsarray进行排序,例如,nsdictionary数组中的键,但我会丢失两个级别深的值。我想做这样的事情,这是psuedo代码:

    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 回复  |  直到 16 年前
        1
  •  1
  •   Yuji    16 年前

    你试过密码了吗?苹果文件( here )表示它接受密钥路径,而不仅仅是密钥。

    推荐文章