gpt4 book ai didi

ios - NSJSONSerialization 编译器警告

转载 作者:行者123 更新时间:2023-11-28 20:05:10 25 4
gpt4 key购买 nike

我正在使用 JSON 来填充带有标记的 mapView。

在方法 -(void)connectionDidFinishLoading:(NSURLConnection *)connection

编译器显示警告:

Incompatible pointer to integer conversion sending 'void *' to parameter of type 'NSJSONReadingOptions' (aka 'enum NSJSONReadingOptions')

在行

categorias_first = [NSJSONSerialization JSONObjectWithData:data_for_first_connection options:nil error:nil];
categorias_second = [NSJSONSerialization JSONObjectWithData:data_for_second_connection options:nil error:nil];
categorias_third = [NSJSONSerialization JSONObjectWithData:data_for_third_connection options:nil error:nil];

这是整个方法代码:

-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
//if data received network indicator not visible
[UIApplication sharedApplication].networkActivityIndicatorVisible=NO;

if(connection==first_connection) {

categorias_first = [NSJSONSerialization JSONObjectWithData:data_for_first_connection options:nil error:nil];

}
else if(connection==second_connection){

categorias_second = [NSJSONSerialization JSONObjectWithData:data_for_second_connection options:nil error:nil];
}
else if(connection==third_connection){

categorias_third = [NSJSONSerialization JSONObjectWithData:data_for_third_connection options:nil error:nil];
}

}

欢迎任何避免警告的帮助。

最佳答案

nil 被视为 ((void*)0) 并且具有指针类型,但是 NSJSONReadingOptions(作为枚举)是整数类型.

options:nil 替换为 options:0

例如:

    categorias_first = [NSJSONSerialization JSONObjectWithData:data_for_first_connection options:0 error:nil];
........

关于ios - NSJSONSerialization 编译器警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22342198/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com