0

こんにちは、このコード行があります。

cell.detailTextLabel.text = [[self->jsonArray objectAtIndex:indexPath.row] objectForKey:@"city"];

2 つの objectForKeys を使用したいと考えています。私は「都市」と「州」のキーを持っており、そのdetailedTextLabelにまとめてもらいたいと思っています。どうすればいいですか?

4

5 に答える 5

5
cell.detailTextLabel.text = [NSString stringWithFormat:@"%@, %@",
                             [[self->jsonArray objectAtIndex:indexPath.row] objectForKey:@"city"], 
                             [[self->jsonArray objectAtIndex:indexPath.row] objectForKey:@"state"]];
于 2012-06-11T09:58:46.930 に答える
1

次のようなことができます。

NSString *city = [[self->jsonArray objectAtIndex:indexPath.row] objectForKey:@"city"];
NSString *state = [[self->jsonArray objectAtIndex:indexPath.row] objectForKey:@"state"];
NSString *combined = [NSString stringWithFormat:@"%@ (%@)", city, state];
cell.detailTextLabel.text = combined;
于 2012-06-11T09:56:15.260 に答える
1

これを試して:

cell.detailTextLabel.text = [NSString stringWithFormat:@"%@ %@",[[self->jsonArray objectAtIndex:indexPath.row] objectForKey:@"city"],[[self->jsonArray objectAtIndex:indexPath.row] objectForKey:@"state"]];
于 2012-06-11T09:56:25.433 に答える
1
NSString *city = [[self->jsonArray objectAtIndex:indexPath.row] objectForKey:@"city"];
NSString *state =[[self->jsonArray objectAtIndex:indexPath.row] objectForKey:@"state"];
cell.detailTextLabel.text = [NSString stringWithFormat:@"city is : %@  state is: %@", city, state];
于 2012-06-11T10:02:25.400 に答える
0

このようなことを試しましたか?

NSString *city = [[self->jsonArray objectAtIndex:indexPath.row] objectForKey:@"city"];
NSString *state = [[self->jsonArray objectAtIndex:indexPath.row] objectForKey:@"state"];
cell.detailTextLabel.text = [[NSString alloc]initWithFormat:@"%@ %@",city,state];
于 2012-06-11T09:59:13.870 に答える