Identifying and removing white spaces new line and carriage return

Recently i was making an NSMutableArray from a string by separating the string by component, Unfortunately it was filling too many empty useless elements into my array…in order to remove them i used following code

 for (int i=0;i<contentsOfFile.count; i++) 
    {
        if(!([[contentsOfFile objectAtIndex:i]isEqual:@”n”]||[[contentsOfFile objectAtIndex:i]isEqual:@””]||[[contentsOfFile objectAtIndex:i]isEqual:@”rn”]))
        [arrayToBereturned addObject:[contentsOfFile objectAtIndex:i]];
    }
i added only those object which were relevant to an array and returned it
A pat on the back !!

Leave a Reply

Your email address will not be published. Required fields are marked *