I need to remove Null object added by
[mutArrSkills addObject:[NSNull null]];
Do I need to iterate? Is there any function to remove all null values from NSMutableArray?
If need to Iterate, how will I do that?
I need to remove Null object added by
[mutArrSkills addObject:[NSNull null]];
Do I need to iterate? Is there any function to remove all null values from NSMutableArray?
If need to Iterate, how will I do that?
You can use NSMutableArray's removeObjectIdenticalTo:
method, as follows
[mutArrSkills removeObjectIdenticalTo:[NSNull null]];
to remove the null values. No need to iterate.
removeObjectIdenticalTo:
Removes all occurrences of a given object in the array.
Discussion This method uses the indexOfObjectIdenticalTo: method to locate matches and then removes them by using removeObjectAtIndex:. Thus, matches are determined using object addresses. If the array does not contain anObject, the method has no effect (although it does incur the overhead of searching the contents).
You can try doing this,
NSNull *nullValue = [NSNull null];
[mutArrSkills removeObjectIdenticalTo:nullValue];
I hope this helps.
You may iterate like this.
for(int i=0,i<[mutArrSkills count]; i++)
{
if([[mutArrSkills objectAtIndex:i] isKindOfClass:[NSNull Class]])
{
[mutArrSkills removeObjectAtIndex:i];
}
}