Dan*_*iel 12 objective-c nsnumber ios
在下面的代码我得到错误消息:ARC不允许将'int'隐式转换为'NSNumber*'.
我错了什么?
<pre>
<code>
NSDictionary *results = [jsonstring JSONValue];
NSNumber *success = [results objectForKey:@"success"]; // possible values for "success": 0 or 1
if (success == 1) { // ERROR implicit conversion of int to NSNumber disallowed with ARC
}
</code>
</pre>
Run Code Online (Sandbox Code Playgroud)
感谢您的帮助或提示!
亲爱的,丹尼尔
ris*_*shi 27
Erro,因为你正在NSNumber
与之比较int
.
试试 -
if ([success isEqual:[NSNumber numberWithInt:1]])
Run Code Online (Sandbox Code Playgroud)
要么
if ([success intValue] == 1)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
28460 次 |
最近记录: |