iphone将注释传递给数组

问题描述:

我想将自定义注释传递给NSMutableArra以便使用它来填充表视图。 的代码是:iphone将注释传递给数组

在.H我限定NSMutableArray *mapViewAnnotations;

然后在.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导致空。 Perarps无法将MyLocation对象复制到可变阵列中?

在此先感谢。

+1

似乎你从来没有初始化你的NSMutableArray.It默认情况下有一个空值。 – FreeNickname 2013-04-22 18:56:35

+0

http://*.com/questions/6410798/annotation-on-the-map-problem/6411217#6411217 – rptwsthi 2013-04-22 18:58:05

在viewDidLoad或其他方法中初始化这个数组来初始化数组。

_mapViewAnnotations = [NSMutableArray array]; 
+0

你说得对。现在我得到这样的东西:(“”,“”,“” )我可以用它来填充表吗? – doxsi 2013-04-22 19:13:12

+1

正确,现在可以使用MyLocation * nota = [_mapViewAnnotations objectAtIndex:0]访问数组中的对象; //或者适当的索引。 – 2013-04-22 19:15:47

+0

非常感谢!现在很清楚 – doxsi 2013-04-22 19:37:36