Sunday, June 3, 2012

iOS: Null Evaluation Gotcha

Some APIs (e.g TouchJSON) return NSNull (which is an object) instead of "nil" when there are no results.

The usual null evaluation (varname == nil) will not evaluate to true.

You will have to additionally evaluate for ([varname isKindOfClass:[NSNull class]]) as well.

No comments:

Post a Comment