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
}
)
You can use the integerValue
property, which exists on both NSNumber
and NSString
.