Luciano Nascimento
Luciano Nascimento

Reputation: 2600

Json Zero considered as NSNumber and greater as NSstring

When the value of a JSON entry is zero Xcode considers it an NSNumber, and when it is greater as an NSString. The problem is when using a if to check the value, the app crashes in some cases. I would like to check if the JSON value is 0, how should I resolve this?

JSON:

(
    {
    likesCount = 0; // NSNumber
    }
)

(
    {
    likesCount = 1; // NSString
    }
)

Upvotes: 0

Views: 174

Answers (1)

executor21
executor21

Reputation: 4588

You can use the integerValue property, which exists on both NSNumber and NSString.

Upvotes: 2

Related Questions