【发布时间】:2012-09-02 17:20:41
【问题描述】:
如何挑选 NSMutableArray 的某些部分? 来自服务器的一个部署阵列是 2012-09-01 09:00:00 America/Los_Angeles 我正在努力争取时间。 我在想把它变成一个字符串,然后得到它,然后再回到 NSMutablearray 来填充到 tableview 单元格。 我还在看文档
我正在考虑的选项: -subarrayWithRange: componentsSeparatedByString:
更新: 这是我现在正在做的事情来获得约会领域
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableContainers error:&error];
NSDictionary* myslots =[json objectForKey:@"slots"];
self.timesArray = [[NSMutableArray alloc] init];
NSLog(@"allslots: %@", myslots);
for (NSString *slotKey in myslots.allKeys) {
NSDictionary *slot = [myslots valueForKey:slotKey];
for (myDays in slot){
if ([[self.myDays objectForKey:@"isReservable"] isEqualToNumber:[NSNumber numberWithInt:1]])
[self.timesArray addObject:[self.myDays objectForKey:@"begin"]];
//NSLog(@"This is the times count: %@", timesArray.count);
}
}
NSLog(@"These are the times avail: %@", self.timesArray);
[self.tableView reloadData];
}
我最终想要的只是一个时间数组。如果我不清楚,我很抱歉。我在尝试着。请让我知道我可以提供哪些信息来绘制更清晰的画面
【问题讨论】:
-
什么?您的数组中是否有多个日期字符串?或者那是什么?
-
一个 NSMutableArray(或 NSArray)是其他对象的有序容器。如果你想让我们告诉你如何用它的字符串表示来做某事,你将不得不告诉我们数组中实际上是什么类型的对象in。例如,如果它们是 NSDate 对象,将有一种更简单的方法来获取不涉及字符串处理的时间。
-
字典数组,每天都是字典。每天多个时间字段(预约时间)。 9-10, 10-11, 11-12, etc. 所以有 9-1 9-10, 9-1 10-11 等等
-
您应该给出一个输入数组的具体示例和所需的结果。
标签: iphone ios5 nsstring split nsmutablearray