xcode Xcode中指针和整数(id和int)的比较
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13488581/
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
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 02:08:51 来源:igfitidea点击:
Comparison between pointer and integer(id and int) in Xcode
提问by user1765037
While running this
在运行这个
if([SUPApplication ConnectionStatus]==[SUPConnectionStatus_DISCONNECTED])
{......
......}
we are getting a warning like "comparison between pointer and integer(id and int)" Why like that.Is there any functions to parse both into same datatype.
我们收到了一个警告,比如“指针和整数(id 和 int)之间的比较”为什么会这样。是否有任何函数可以将两者解析为相同的数据类型。
回答by Dimitar Marinov
Try to cast them:
尝试投射它们:
if((int)[SUPApplication ConnectionStatus]== (int)SUPConnectionStatus_DISCONNECTED)
回答by Yuliani Noriega
Try making them both into NSNumbersand then compare there values
尝试将它们都放入NSNumbers然后比较它们的值
if ([[NSNumber numberWithInt:[SUPApplication ConnectionStatus]] isEqualToNumber:[NSNumber numberWithInt:SUPConnectionStatus_DISCONNECTED]])
{
....
}

