【发布时间】:2013-07-04 21:47:21
【问题描述】:
我有很多这样的时间:
(
"2000-01-01 23:48:00 +0000",
"2000-01-01 02:15:00 +0000",
"2000-01-01 04:39:00 +0000",
"2000-01-01 17:23:00 +0000",
"2000-01-01 13:02:00 +0000",
"2000-01-01 21:25:00 +0000"
)
由此代码生成:
//loop through array and convert the string times to NSDates
NSDateFormatter *timeFormatter = [[NSDateFormatter alloc] init];
[timeFormatter setDateFormat:@"hh:mm a"];
NSMutableArray *arrayOfDatesAsDates = [NSMutableArray array];
for (NSObject* o in arrayTimes)
{
NSLog(@"%@",o);
NSDate *nsDateTime = [timeFormatter dateFromString:o];
[arrayOfDatesAsDates addObject:nsDateTime];
}
NSLog(@"times array: %@", arrayOfDatesAsDates);//
我这样做是因为我试图获取下一个数组中的时间。我的计划是删除过去的时间,订购它们,然后将第一个作为下一次。
如何删除过去的?
谢谢
【问题讨论】:
-
鉴于日期都是 2000 年,最简单的方法是清空数组...
-
谁知道!?除了您之外,没有其他人知道 arrayTimes 究竟包含什么。
-
@MarcB 嗯,这只是样本数据,它每次都会改变......
标签: objective-c nsarray nsdate