我正在使用自定义表格单元,但是在我的 uilabel 中解析 JSON 时遇到问题,我正在使用下面的代码,这很好用。在我的 UILabel 中放一些东西我很简单
cell.One.text = @"xx";
/
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CustomCellIdentifier = @"CustomCellIdentifier ";
CustomCell *cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier: CustomCellIdentifier];
if (cell == nil) {
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CustomCell"
owner:self options:nil];
for (id oneObject in nib) if ([oneObject isKindOfClass:[CustomCell class]])
cell = (CustomCell *)oneObject;
}
return cell;
}
但是当我尝试解析我通常会做的事情时
- (void)fetchedData:(NSData *)responseData {
NSError* error;
NSDictionary* json = [NSJSONSerialization JSONObjectWithData:responseData //1
options:kNilOptions
error:&error];
NSArray* lastgame = [json objectForKey:@"items"];
NSDictionary* game = [lastgame objectAtIndex:0];
cell.One.text = [NSString stringWithFormat:@"%@",
[strijd objectForKey:@"One"]
];
}
但是在这一行我收到一个错误:(使用未声明的标识符'cell')现在有人如何修复thix?
cell.One.text = [NSString stringWithFormat:@"%@",
[strijd objectForKey:@"One"]
];