程序在下面的注释行崩溃。不知道出了什么问题。给第一次程序员的任何提示?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MainCell"];
if(cell == nil){
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"MainCell"];
}
cell.textLabel.text = [[users objectAtIndex:indexPath.row] objectForKey:[[NSString alloc] initWithFormat:@"%d", indexPath.row]];
//My program runs but then crashes at this line, I have no idea what's wrong with it though "reason: '-[__NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance"
return cell;
}
一些更多的代码(虽然不是全部)根据要求
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
users = [NSJSONSerialization JSONObjectWithData:data options:nil error:nil];
[self.tableView reloadData];
}
- (int)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [users count];
}
在 .h 文件中
@interface GIFUsersListViewController : UITableViewController {
NSArray *users; NSMutableData *data;
} @结尾