1

I am trying to pass custom annotation to a NSMutableArra in order to use it to populate a table view. The code is:

in .h I define a NSMutableArray *mapViewAnnotations;

then in the .m

- (void)plotBarPosition:(NSString *)datos{

/*
code that extract data froma a json string
*/
    MyLocation *nota =[[MyLocation alloc] initWithName:barNamePlusDistance coordinate:coordinate horario:horario oferta:offerta more:info];        
                NSLog(@"nota    :%@",nota);

            [_mapView addAnnotation:nota];   //annotation are  plot on  the map

            [mapViewAnnotations addObject:nota];   

            NSLog(@"mapViewAnnotations:%@",mapViewAnnotations);  //NSlog return null
    }

mapViewAnnotations results null. Perarps It is not possible to copy MyLocation object into a mutablearray?

Thanks in advance.

doxsi
  • 1,002
  • 19
  • 42

1 Answers1

1

Call this first in viewDidLoad or other method to init the array.

_mapViewAnnotations = [NSMutableArray array];
Mark McCorkle
  • 9,349
  • 2
  • 32
  • 42
  • You are right. Now I get something like that : ( "","","" ) Can i use it to fill a table? – doxsi Apr 22 '13 at 19:13
  • 1
    Correct, you can now access the objects in the array using MyLocation *nota = [_mapViewAnnotations objectAtIndex:0]; // Or the appropriate index. – Mark McCorkle Apr 22 '13 at 19:15