我該如何挑出NSMutableArray的某個部分? 來自服務器的一個現場陣列是2012-09-01 09:00:00 America/Los_Angeles 我正在努力爭取時間。 我在想它變成一個字符串,然後得到它,然後回到NSMutablearray填充到tableview單元格。 我仍然在尋找在文檔挑出NSMutableAray的某個部分
選項我想到的是: -subarrayWithRange: componentsSeparatedByString:
UPDATE: 這裏是我現在所做的得到任命領域
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];
}
我最終想要的只是一個時代的陣列。如果我不清楚,我很抱歉。我在嘗試着。請讓我知道我可以提供給描繪出清晰的畫面
什麼?數組中是否有多個日期字符串?或者那是什麼? – 2012-09-02 17:22:39
NSMutableArray(或NSArray)是其他對象的有序容器。如果您希望我們告訴您如何使用字符串表示進行操作,您將不得不告訴我們**數組中的實際**對象。例如,如果它們是NSDate對象,那麼可以更簡單地獲得不涉及字符串處理的時間。 – UIAdam
字典數組,每天都是字典。每天有多個時間字段(約會時間)。 9-10,10-11,11-12等。所以有9-1 9-10,9-1 10-11等等 – TIDev