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对象复制到可变阵列中?
在此先感谢。
答
在viewDidLoad或其他方法中初始化这个数组来初始化数组。
_mapViewAnnotations = [NSMutableArray array];
似乎你从来没有初始化你的NSMutableArray.It默认情况下有一个空值。 – FreeNickname 2013-04-22 18:56:35
http://*.com/questions/6410798/annotation-on-the-map-problem/6411217#6411217 – rptwsthi 2013-04-22 18:58:05