Objective-C how to check if a string is null

Posted by norskben on Stack Overflow See other posts from Stack Overflow or by norskben
Published on 2010-03-08T12:29:29Z Indexed on 2010/03/08 12:36 UTC
Read the original article Hit count: 972

Filed under:
|
|

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: 'NSArray' may not respond to'-objectForKey:'
  • warning: comparison of distinct Objective-C types 'struct NSNull *' and 'struct 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?

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about nil