iOS Implicit conversion of int to NSNumber is disallowed with ARC

Question:

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!

Answer:

Erro because you are comparing NSNumber with int.

Try like –

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

or

if ([success intValue] == 1)
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s