Thursday 5 July 2012

Remove Null Value From array and add real from from array...

If one array where we fetching data from database for some 
specific value,and hence the key where that particular value is not 
there,it is fetching null value in the array. 
 
 Then for removing these values just use bellow code...
 
NSMutableArray *array = [[NSMutableArray alloc]init];
array = [InteName retain];
NSLog(@"Array : : %@",array);
NSMutableArray *array1 = [[NSMutableArray alloc]init];
NSString *str;
for(int i=0;i<[array count];i++)
{
    str = [array objectAtIndex:i];
    if(str !=[NSNull null])
    {
        [array1 addObject:str]; 
        //[array removeObjectAtIndex:i];
    }
}

No comments:

Post a Comment