SO
I wish to check to see if the item in my array [clientDataArray objectForKey:@"ClientCompany"] is nil.
temp = [clientDataArray objectForKey:@"ClientCompany"];
if (temp != [NSNull null]) infofieldCompany.text = temp;
So far I have been able to achieve this through the above code, but it does give me the warnings
- warning:
NSArraymay not respond to-objectForKey: - warning: comparison of distinct
Objective-C typesstruct NSNull *
andstruct NSString *lacks a cast
My main interest is the second warning, but the first warning also interest me.
How should I adapt my above code?
Your first warning looks like you’re trying to call
objectForKeyon anNSArray. Which isn’t going to work, asNSArraydoesn’t have anobjectForKeymethod.As for the second warning you can just compare directly with nil, ie:
or since nil is equivalent to 0, you can also just do: