【问题标题】:Sorting of Date String using sortUsingDescriptors?使用排序使用描述符对日期字符串进行排序?
【发布时间】:2011-04-12 06:44:28
【问题描述】:

我有很多字典数组

   points = 200;
   startDate = "Jun 04, 2011, 13:15 PM";

   points = 200;
   startDate = "May 01, 2011, 11:15 PM";

   and  -------

我必须根据 startDate 进行排序。

我已经通过这种方法使用过数字排序的数字..字母排序等:

-(NSMutableArray*)SortEventsArray:(NSMutableArray*)arrayToSort :(NSString*)sortExpression
{
   NSSortDescriptor *mySorter = [[NSSortDescriptor alloc] initWithKey:sortExpression ascending:YES];
   [arrayToSort sortUsingDescriptors:[NSMutableArray arrayWithObject:mySorter]];
   return arrayToSort;
}

但它不适用于日期字符串。

请帮忙

【问题讨论】:

    标签: iphone nsmutablearray nsdate nsdateformatter nssortdescriptor


    【解决方案1】:

    Chekout this

    This one also

    两者都会帮助你。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-04
      • 1970-01-01
      • 2022-06-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多