Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Implicit conversion of int to NSNumber is disallowed with ARC

Tags:

on following code i'm get the errormessage: Implicit conversion of 'int' to 'NSNumber *' is disallowed with ARC.

What i'm making wrong?

<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>

Thanks for any help or hint!

regards, Daniel

like image 513
Daniel Avatar asked May 18 '12 10:05

Daniel


1 Answers

Erro because you are comparing NSNumber with int.

Try like -

if ([success isEqual:[NSNumber numberWithInt:1]])

or

if ([success intValue] == 1)
like image 197
rishi Avatar answered Oct 11 '22 19:10

rishi