我正在尝试从数组中获取一些数据并将其打印在Xcode中的UILabel上,但我收到了警告:
从'NSArray *'
分配给'NSString *'的指针类型不兼容
这是我的代码:
NSError *myError = nil;
NSDictionary *res = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableLeaves error:&myError];
NSArray *results = [res objectForKey:@"current_observation"];
NSArray *cur = [results valueForKey:@"weather"];
NSArray *tmp = [results valueForKey:@"temp_c"];
NSLog(@"Current conditions: %@, %@º", cur, tmp);
temp.text = (@"%@", tmp);
答案 0 :(得分:3)
而不是:
temp.text = (@"%@", tmp);
使用此:
temp.text = [tmp componentsJoinedByString:@""];