xcode 不兼容的整数转换指针将“void *”发送到“NSJSONReadingOptions”类型的参数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15173565/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Incompatible pointer to integer conversion sending 'void *' to parameter of type 'NSJSONReadingOptions'
提问by Brandon
I am getting a weird compiler warning. It says:
我收到一个奇怪的编译器警告。它说:
Incompatible pointer to integer conversion sending 'void *' to parameter of type
'NSJSONReadingOptions' (aka 'enum NSJSONReadingOptions')
Here is the block that its in:
这是它所在的块:
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
//Incompatible pointer to integer conversion sending 'void *' to parameter of type
'NSJSONReadingOptions' (aka 'enum NSJSONReadingOptions')
news = [NSJSONSerialization JSONObjectWithData:data options:nil error:nil];
[mainTableView reloadData];
}
Any ideas how to fix this? Thank you!
任何想法如何解决这一问题?谢谢!
回答by Martin R
Just replace options:nil
by options:0
.
只需替换options:nil
为options:0
.
nil
is ultimately defined as ((void*)0)
and has pointer type, but NSJSONReadingOptions
(as an enum) is a integer type.
nil
最终定义为((void*)0)
并具有指针类型,但NSJSONReadingOptions
(作为枚举)是整数类型。