I am getting error object cannot be nil. I am using web service, when I parse it using loop it crashed and send output -[__NSArrayM insertObject:atIndex:]:
object cannot be nil as error, because I have null value on blank value in NSMutableArray
which I am trying to parse.
I tried to fix with these methods:
(1) if([Array containsObject:[NSNull null]])
(2) if([Array objectAtIndex:0
(3) if([Array objectAtIndex:counter] == 0**
My code is,
if([[[node childAtIndex:counter] name] isEqualToString:@"Phone"]){
if([phoneno containsObject:[NSNull null]]){
phone.text = @"-";
}
else{
NSString *str = [[node childAtIndex:counter] stringValue];
[phoneno addObject:str];
NSString *myString = [phoneno componentsJoinedByString:@","];
[phone setText:myString];
phone.text = [NSString stringWithFormat:@"%@",myString];
}
}
Here, phoneno is NSMutableArray