Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 创建字符串时参数太多_Ios_Objective C_Json - Fatal编程技术网

Ios 创建字符串时参数太多

Ios 创建字符串时参数太多,ios,objective-c,json,Ios,Objective C,Json,我下载了一个JSON文件,然后尝试用下载的字典中的一个值创建一个字符串 我正在使用的代码: NSMutableDictionary *tempDict = [listaShowsFiltrada objectAtIndex:indexPath.row]; NSLog(@"%@", tempDict); cell.labelLugar.text = [tempDict objectForKey:@"local"]; //This is working NSString *stringCidad

我下载了一个JSON文件,然后尝试用下载的字典中的一个值创建一个字符串

我正在使用的代码:

NSMutableDictionary *tempDict = [listaShowsFiltrada objectAtIndex:indexPath.row];
 NSLog(@"%@", tempDict);
cell.labelLugar.text = [tempDict objectForKey:@"local"]; //This is working

NSString *stringCidadeEstado = [[NSString alloc] initWithString:@"%@ - %@", [[tempDict objectForKey:@"cidade"] stringValue], [[tempDict objectForKey:@"estado"] stringValue]]; //This is not working
NSLog:

2014-04-27 11:57:46.645  {
    cidade = "S\U00e3o Paulo";
    "cod_agenda" = 15;
    data = "05/05/2014";
    estado = SP;
    "hora_show" = "22:00";
    local = "Teatro Renaissance";
}
2014-04-27 11:57:46.655  {
    cidade = "Belo Horizonte";
    "cod_agenda" = 16;
    data = "06/06/2014";
    estado = MG;
    "hora_show" = "22:00";
    local = "Teatro Sesi Minas";
}
2014-04-27 11:57:46.656 {
    cidade = Curitiba;
    "cod_agenda" = 14;
    data = "14/06/2014";
    estado = PR;
    "hora_show" = "22:00";
    local = "Teatro Regi Vogue";
}
JSON文件:

[{"cod_agenda":"15","local":"Teatro Renaissance","cidade":"S\u00e3o Paulo","estado":"SP","data":"05\/05\/2014","hora_show":"22:00"},{"cod_agenda":"16","local":"Teatro Sesi Minas","cidade":"Belo Horizonte","estado":"MG","data":"06\/06\/2014","hora_show":"22:00"},{"cod_agenda":"14","local":"Teatro Regi Vogue","cidade":"Curitiba","estado":"PR","data":"14\/06\/2014","hora_show":"22:00"}]
错误:

Too many arguments to method call, expected 1, have 3.

方法initWithString只接受一个参数,您希望使用initWithFormat:

NSString *stringCidadeEstado = [[NSString alloc] initWithFormat:@"%@ - %@", [[tempDict objectForKey:@"cidade"] stringValue], [[tempDict objectForKey:@"estado"] stringValue]];

方法initWithString只接受一个参数,您希望使用initWithFormat:

NSString *stringCidadeEstado = [[NSString alloc] initWithFormat:@"%@ - %@", [[tempDict objectForKey:@"cidade"] stringValue], [[tempDict objectForKey:@"estado"] stringValue]];

方法initWithString只接受一个参数,您希望使用initWithFormat:

NSString *stringCidadeEstado = [[NSString alloc] initWithFormat:@"%@ - %@", [[tempDict objectForKey:@"cidade"] stringValue], [[tempDict objectForKey:@"estado"] stringValue]];

方法initWithString只接受一个参数,您希望使用initWithFormat:

NSString *stringCidadeEstado = [[NSString alloc] initWithFormat:@"%@ - %@", [[tempDict objectForKey:@"cidade"] stringValue], [[tempDict objectForKey:@"estado"] stringValue]];