Q:

NSMutableArray parsing csv not working?

I have this code where I use NSMutableArray to parse a csv file. There are no errors that stop me from running the app however the map doesn't display anything.
 NSString *csvFilePath = [[NSBundle mainBundle] pathForResource:@"Data2"   ofType:@"csv"];
NSString *dataStr = [NSString stringWithContentsOfFile:csvFilePath encoding:NSUTF8StringEncoding error:nil];

NSMutableArray *allLinedStrings = [[NSMutableArray alloc]initWithArray:[dataStr componentsSeparatedByString:@"\r"]];

NSMutableArray *latitude = [[NSMutableArray alloc]init];
NSMutableArray *longitude = [[NSMutableArray alloc]init];
NSMutableArray *description = [[NSMutableArray alloc]init];
NSMutableArray *address = [[NSMutableArray alloc]init];
NSMutableArray *temperature = [[NSMutableArray alloc]init];
NSMutableArray *time = [[NSMutableArray alloc]init];
NSMutableArray *ambient = [[NSMutableArray alloc]init];

NSMutableArray *filteredLocations = [NSMutableArray array];
MKMapPoint* pointArr = malloc(sizeof(MKMapPoint) * filteredLocations.count);

for (int idx = 0; idx < [allLinedStrings count]; idx++)
{
NSMutableArray *infos = [[NSMutableArray alloc]initWithArray:[[allLinedStrings objectAtIndex:idx] componentsSeparatedByString:@","]];
    if ([infos count] > 1)
    {
        [latitude addObject:[infos objectAtIndex:4]];
        [longitude addObject:[infos objectAtIndex:5]];
        [description addObject:[infos objectAtIndex:0]];
        [address addObject:[infos objectAtIndex:10]];
        [temperature addObject:[infos objectAtIndex:6]];
        [time addObject:[infos objectAtIndex:15]];
        [ambient addObject:[infos objectAtIndex:8]];

        if([[latitude objectAtIndex:4] isEqualToString:@"NULL"] || [[longitude objectAtIndex:5] isEqualToString:@"NULL"] || [[description objectAtIndex:0] isEqualToString:@"NULL"] ||  [[address objectAtIndex:10]isEqualToString:@"NULL"] ||  [[temperature objectAtIndex:6] isEqualToString:@"NULL"] ||  [[time objectAtIndex:15]isEqualToString:@"NULL"] ||  [[ambient objectAtIndex:8] isEqualToString:@"NULL"]) {continue;}

        CLLocationCoordinate2D coordinate;
        coordinate.latitude = [[latitude objectAtIndex:4] doubleValue];
        coordinate.longitude = [[longitude objectAtIndex:5] doubleValue];
        Location *annotation = [[Location alloc] initWithName:[description objectAtIndex:0] address:[address objectAtIndex:10] temperature:[temperature objectAtIndex:6] time:[time objectAtIndex:15] ambient:[ambient objectAtIndex:8] coordinate:coordinate] ;
        [mapview addAnnotation:annotation];
        [filteredLocations addObject:annotation];

        MKMapPoint point = MKMapPointForCoordinate(coordinate);

        pointArr[idx] = point;

    }

}

self.routeLine = [MKPolyline polylineWithPoints:pointArr count:filteredLocations.count];
[self.mapview addOverlay:self.routeLine];
free(pointArr);

        MKMapRect zoomRect = MKMapRectNull;
        for (id <MKAnnotation> annotation in mapview.annotations)
        {
            MKMapPoint annotationPoint = MKMapPointForCoordinate(annotation.coordinate);
            MKMapRect pointRect = MKMapRectMake(annotationPoint.x, annotationPoint.y, 0.1, 0.1);
            zoomRect = MKMapRectUnion(zoomRect, pointRect);
        }
        [mapview setVisibleMapRect:zoomRect animated:YES];

        self.mapview.delegate = self;

    }

I guess there must be something wrong with how I'm calling the objects or maybe the MKMapPoint but I don't manage to find what's blocking the app from displaying the data. I've tried using both "initWithObjects" and removing "if ([infos count] > 1){" but when ran it crashed showing a breakdown point in "NSMutableArray *latitude = [[NSMutableArray alloc]init];".

A:

Based on your previous questions about this project, you want to do the following at a high level:

Parse a CSV file where each line has coordinate data.  Ignore lines that have "null" data.  (For the purpose of this answer, let's ignore that one could use a pre-built CSV parser, or use a different format altogether.)
Show annotations for lines with "good" data.
Connect all the annotations with a line.

For requirement 1 (R1), you already know how to load the CSV file, loop through the lines, and identify the lines with "null" data.
For requirement 2 (R2), after some research, you know that you can create and add annotations to the map one at a time and the map doesn't need to know ahead of time how many you will add so that means the first two requirements could be done in the same loop.
For requirement 3 (R3), after some research, you know that to create and add a polyline to the map, you need to know ahead of time how many points will be in the line.  
For R1 and R2, you will be looping through the lines of the CSV and identify the non-null lines.  
So that means you will know how many points will be in the polyline after the loop that handles R1 and R2.  That means the polyline must be created after that loop.
But to create the polyline, you need not just the point count but the coordinates for each point as well.  
That means while looping through the lines in the CSV, you need to save the coordinate data somewhere (in the same order it appeared in the CSV).
In Objective-C, a convenient structure that allows you to add data to it without knowing in advance how many objects will be added is an NSMutableArray.

So now we have this very high-level plan:

Loop through the CSV file, ignore lines with null data, create and add annotations, add the line data to an NSMutableArray (NSMA).
Create a polyline using the point data in NSMA, add the polyline to the map.

With this plan, we see we need one NSMutableArray.  Notice that in the existing code, you have a Location class that holds (or could hold) all the data from each line of the CSV.  
That means we could simply add these Location objects to the NSMA.  NSMutableArrays can hold any type of object (they don't have to be just NSStrings).

So here's a slightly more detailed plan:

Initialize an NSMutableArray called filteredLocations (eg. NSMutableArray *filteredLocations = [NSMutableArray array];).
Loop through the CSV file, ignore lines with null data, create a Location object and add as an annotation, add the Location object to filteredLocations (eg. [filteredLocations addObject:annotation];).
Initialize (malloc) a C array to hold the points of the polyline with the point count being the count of filteredLocations.
Loop through filteredLocations, add point from filteredLocations to the C array.
Create and add a polyline to the map.

In this plan note we have two separate loops: The first one is for R1 and R2.  The second one is for R3.

If required, I will post sample code that implements this plan.

First, just to explain your latest NSRangeException error, it is happening  on this line:
if([[latitude objectAtIndex:4] isEqualToString:@"NULL"] || ...

because you've declared latitude as an array and the first time the if executes in the loop, latitude only has one object (a few lines above this if you do [latitude addObject:...).  The index of an array starts at zero so the bounds of an array with one object are zero to zero hence the error message saying index 4 beyond bounds [0 .. 0].
There are many other issues with the rest of the code.
There is not enough room in this answer to explain in detail.  
I urge you, if possible, to stop, step back and re-start with a much simpler project or tutorials and, most importantly, learn the absolute basics of programming in general.
Here is an example of code that should work based on your sample data:
-(void)viewDidLoad
{
    [super viewDidLoad];

    self.mapview.delegate = self;

    NSString *csvFilePath = [[NSBundle mainBundle] pathForResource:@"Data2" ofType:@"csv"];
    NSString *dataStr = [NSString stringWithContentsOfFile:csvFilePath encoding:NSUTF8StringEncoding error:nil];

    NSArray *allLinedStrings = [dataStr componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]];

    NSMutableArray *filteredLocations = [NSMutableArray array];

    for (int idx = 0; idx < [allLinedStrings count]; idx++)
    {
        NSArray *infos = [[allLinedStrings objectAtIndex:idx] componentsSeparatedByString:@","];

        if ([infos count] > 15)
        {
            NSString *latitude = [infos objectAtIndex:4];
            NSString *longitude = [infos objectAtIndex:5];
            NSString *description = [infos objectAtIndex:0];
            NSString *address = [infos objectAtIndex:10];
            NSString *temperature = [infos objectAtIndex:6];
            NSString *time = [infos objectAtIndex:15];
            NSString *ambient = [infos objectAtIndex:8];

            if([latitude isEqualToString:@"NULL"]
               || [longitude isEqualToString:@"NULL"]
               || [description isEqualToString:@"NULL"]
               || [address isEqualToString:@"NULL"]
               || [temperature isEqualToString:@"NULL"]
               || [time isEqualToString:@"NULL"]
               || [ambient isEqualToString:@"NULL"])
            {
                continue;
            }

            CLLocationCoordinate2D coordinate;
            coordinate.latitude = [latitude doubleValue];
            coordinate.longitude = [longitude doubleValue];

            Location *annotation = [[Location alloc] initWithName:description
                                                          address:address
                                                      temperature:temperature
                                                             time:time
                                                          ambient:ambient
                                                       coordinate:coordinate];
            [mapview addAnnotation:annotation];

            [filteredLocations addObject:annotation];
        }
    }

    MKMapPoint* pointArr = malloc(sizeof(MKMapPoint) * filteredLocations.count);

    for (int flIndex = 0; flIndex < filteredLocations.count; flIndex++)
    {
        Location *location = [filteredLocations objectAtIndex:flIndex];
        MKMapPoint point = MKMapPointForCoordinate(location.coordinate);
        pointArr[flIndex] = point;
    }

    self.routeLine = [MKPolyline polylineWithPoints:pointArr count:filteredLocations.count];
    [self.mapview addOverlay:self.routeLine];
    free(pointArr);

    [self.mapview showAnnotations:self.mapview.annotations animated:YES];
}

