create CLLocationCoordinate2D from array
        Posted  
        
            by 
                shani
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by shani
        
        
        
        Published on 2011-01-04T23:17:47Z
        Indexed on 
            2011/01/05
            6:53 UTC
        
        
        Read the original article
        Hit count: 226
        
I have a plist with dictionary of array's with coordinates (stored as strings).
I want to create a CLLocationCoordinate2D from every array and crate an overlay for the map.
I did that -
NSString *thePath = [[NSBundle mainBundle]  pathForResource:@"Roots" ofType:@"plist"];
    NSDictionary *pointsDic = [[NSDictionary alloc] initWithContentsOfFile:thePath];
 NSArray *pointsArray = [NSArray arrayWithArray:[pointsDic objectForKey:@"roade1"]];
 CLLocationCoordinate2D pointsToUse[256];
 for(int i = 0; i < 256; i++) {
  CGPoint p = CGPointFromString([pointsArray objectAtIndex:i]);
  pointsToUse[i] = CLLocationCoordinate2DMake(p.x,p.y);
  NSLog(@"coord %f",pointsToUse [i].longitude);
  NSLog(@"coord %f",pointsToUse [i].latitude);
 }
 MKPolyline *myPolyline = [MKPolyline polylineWithCoordinates:pointsToUse count:256];
 [[self mv] addOverlay:myPolyline];
but the app is crashing without any error. (BTW when i remove the addOverLay method the app does not crash).
I have 2 questions-
- What am i doing wrong?
- I have tried to set the pointsArray count as the argument for the CLLocationCoordinate2D like that - - CLLocationCoordinate2D pointsToUse[pointsArray count]; 
And i am getting an error. How can i set the CLLocationCoordinate2D dynamically ?
Thanks for any help. Shani
© Stack Overflow or respective owner