Reputation: 171
I am getting this error on the conditional if statement. Is there a good way to prevent this error from showing up? Any tips or suggestions are appreciated. I am guessing subanswer for some reason is a boolean.
id subAnswer = [answer objectForKey:@"answer"];
NSArray *subAnswerKeyList;
if (subAnswer != [NSNull null] && subAnswer != nil && [subAnswer count] > 0 ) {
...
}
Upvotes: 0
Views: 728
Reputation: 318804
Replace your if
statement with:
if ([subAnswer isKindOfClass:[NSArray class]] && [subAnswer count]) {
}
Your subAnswer
is actually a number representing a BOOL
value. You need to see why you expect it to be an array.
Upvotes: 2
Reputation: 89509
your "subAnswer
" object is almost certainly not the NSArray object you're expecting it to be.
Put a "NSLog("subAnswer is %@", subAnswer);
" in your code there and your Xcode console will tell you what the object really is.
Upvotes: 0