I have a problem that should be quite common. I have an Array of data called taskList this comes from a JSON and has several user data. So far, so good. I make the first objectForKey:@"desc" and returns the result (Description of user) but when I try to add another objectForKey (age for example) it shows only the age 🙁 This is the code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = nil;
cell = [tableView dequeueReusableCellWithIdentifier:@"MyCell"];
if (cell == nil){
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"MyCell"] autorelease];
}
NSLog(@"%@",taskList);
cell.textLabel.text = [[taskList objectAtIndex:indexPath.row] objectForKey:@"desc"];
return cell;
cell.textLabel.text = [[taskList objectAtIndex:indexPath.row] objectForKey:@"age"];
return cell;
}
do this instead:
Another example, which formats the string (in this case the only difference is that I’m adding a space between the two but it introduces you to a very very helpful method) (and uses the two strings that we created above):
Or to do the same thing without the temporary variable
textForMyLabeluse: