How to check if value in array is not NULL?

ios, iphone, objective-c, xcode

Solution

`NSArray` and other collections can't take `nil` as a value, since nil is the "sentinel value" for when the collection ends. You can find if an object is null by using:

if (myObject == [NSNull null]) {
    // do something because the object is null
}

Problem

So I am parsing a twitter timeline. There is a field called "following" in the JSON response. It should be true or false. But sometimes the field is missing. When I do: ``` NSLog(@"%@", [[[timeline objectAtIndex:i] objectForKey:@"user"] objectForKey:@"following"]); ``` This is the output: ``` 1 1 0 0 1 <null> 1 1 ``` So how to check for those values?

Original source