我的应用程序正在加载一些数据 认为JSON,一切都正常, 但是当我试图在我的UITView 单元格中显示这些数据时, 什么也没有发生。 我的代码如下:
获取数据( JSON) :
-(void)fetchedData:(NSData *)responseData {
NSError* error;
NSDictionary* json = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&error];
NSArray* latestLoans = [json objectForKey:@"loans"];
testeDictionary = [latestLoans objectAtIndex:0];
testeLabel.text = [NSString stringWithFormat:@"%@",[testeDictionary objectForKey:@"id"]];
testeString = [testeDictionary objectForKey:@"username"];
[miArray addObject:[NSDictionary dictionaryWithObjectsAndKeys:testeString,@"username",nil]];
}
Uitable View :
-(UITableViewCell *)tableView:(UITableView *)myTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = (UITableViewCell *)[self.settingsTableView dequeueReusableCellWithIdentifier:@"CellD"];
if (cell == nil) {
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CellD" owner:self options:nil];
cell = (UITableViewCell *)[nib objectAtIndex:0];
}
if ([indexPath row] == 0) {
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CellA" owner:self options:nil];
cell = (UITableViewCell *)[nib objectAtIndex:0];
NSDictionary *itemAtIndex = (NSDictionary *)[miArray objectAtIndex:indexPath.row];
UILabel *usernameString = (UILabel *)[cell viewWithTag:1];
usernameString.text = [itemAtIndex objectForKey:@"id"]; <== MUST DISPLAY JSON VALUE
}
return cell;
}
更明确地说,我需要在 [testeDigitary 物件ForKey:@“id”]
上显示 用户名String. text
?