我无法理解如何用所有日期填充我的表格。仅返回 2012 年 9 月 1 日,而不是 2012 年 8 月 31 日。我已经尝试了一些事情,比如在 numberofrows 部分中使用我的日子和时段。我认为它与 .count 有关,但没有看到在哪里。但我还没有弄清楚。它仍然只发布 9/1 字典。如何在 tableviewcell 中显示所有字典数组,我希望我有意义,附上图片。我的代码:
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableContainers error:&error];
NSDictionary* myslots =[json objectForKey:@"slots"];
NSLog(@"allslots: %@", myslots);
for (NSString *slotKey in myslots.allKeys) {
NSDictionary *slot = [myslots valueForKey:slotKey];
UPDATED:
self.timesArray = [[NSMutableOrderedSet alloc] init];
for (NSDictionary *myDays in slot){
if ([[myDays objectForKey:@"isReservable"] isEqualToNumber:[NSNumber numberWithInt:1]])
[self.timesArray addObject:[myDays objectForKey:@"begin"]];
//NSLog(@"This is the times count: %@", timesArray.count);
}
NSLog(@"These are the times avail: %@", self.timesArray);
[self.tableView reloadData];
}
}
看起来是这样的:
2012-08-31 16:34:57.074 GBSB[780:15b03] These are the times avail: {(
"2012-08-31 09:00:00 America/Los_Angeles",
"2012-08-31 13:00:00 America/Los_Angeles",
"2012-08-31 14:00:00 America/Los_Angeles",
"2012-08-31 15:00:00 America/Los_Angeles",
"2012-08-31 16:00:00 America/Los_Angeles"
)}
2012-08-31 16:34:57.074 GBSB[780:15b03] These are the times avail: {(
"2012-09-01 09:00:00 America/Los_Angeles",
"2012-09-01 10:00:00 America/Los_Angeles",
"2012-09-01 11:00:00 America/Los_Angeles",
"2012-09-01 12:00:00 America/Los_Angeles",
"2012-09-01 13:00:00 America/Los_Angeles",
"2012-09-01 14:00:00 America/Los_Angeles",
"2012-09-01 15:00:00 America/Los_Angeles",
"2012-09-01 16:00:00 America/Los_Angeles"
)}
这是我在.h中尝试过的
@property (nonatomic, retain) NSMutableOrderedSet *timesArray;
.m
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
//#warning Incomplete method implementation.
// Return the number of rows in the section.
return self.timesArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// Configure the cell...
//cell.textLabel.text = timesArray;
cell.textLabel.text = [self.timesArray objectAtIndex:indexPath.row];
return cell;
这是一张照片