Search code examples
iosiphoneobjective-cnsmutablearray

How to add string object in nsmutable array if some string is empty


arrdata=[[NSMutableArray alloc]initWithObjects:strname,strWeb,strAdd,strPhone,strrate, nil];  
[arrAllData addObject:arrdata];

I fetched data from a webservice. in my condition if strweb has no value then it simply ignores other values like stradd,sphone and strrate. How can I solve this problem?


Solution

  • you can do like this in a simplest way.

    if(strweb==nil)  
    {  
      strweb=@"null";   
    }
    

    Note: pass null in <> bracket;