当我对 NSMutableArray 的内容执行 NSLog 时,它返回:
(
hat,
hat
)
那么为什么当我像这样执行 NSLog 时NSLog(@"%@", [pro.matches objectAtIndex:0]);
它会因错误而崩溃:*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'
这么奇怪
这是我填写的地方:
[self.matches removeAllObjects];
NSArray *JSONarray = [[NSArray alloc] initWithArray:[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:nil]];
int i;
for (i=0; i<[JSONarray count]; i++) {
//[self.matches addObject:[JSONarray objectAtIndex:i]];
[self.matches addObject:@"hat"];
}
//NSLog(@"boys with bo%@", [[matches objectAtIndex:1] objectForKey:@"host"]);
block();
//JSON and add to matches.
}
}];
block();
这就是我所说的:
[pro refreshMatchesWithCallback:^
{
//[self.tableView reloadData];
NSLog(@"the count of a lifetime is %@", [pro.matches objectAtIndex:0]);
}];