Reputation: 2600
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
Reputation: 4588
You can use the integerValue
property, which exists on both NSNumber
and NSString
.
Upvotes: 2