`
lizaochengwen
  • 浏览: 644664 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

[mapView removeAnnotations:arr]; 这样老报错,为什么:

 
阅读更多
NSArray *arr = [mapView annotations];
[mapView removeAnnotations:arr];

百度地图api,这样删除图钉总是报错,求解释,错误信息如下

2012-02-10 22:35:29.106 BaiduMapSW[7782:707] *** Terminating app due to uncaught exception 'NSGenericException', reason: '*** Collection <__NSArrayM: 0x2c1690> was mutated while being enumerated.'
*** First throw call stack:
(0x33d588bf 0x33fa81e5 0x33d583e3 0xaa0d 0x52c7 0x368f 0x33cb2435 0x3711c9eb 0x3711c9a7 0x3711c985 0x3711c6f5 0x3711d02d 0x3710f99b 0x33d2cb4b 0x33d2ad87 0x33d2b0e1 0x33cae4dd 0x33cae3a5 0x30532fcd 0x3712f743 0x21e3 0x2188)
terminate called throwing an exception(gdb)

找到解决方法了


NSArray* array = [NSArray arrayWithArray:mapView.annotations];
[mapView removeAnnotations:array];
应该把数组复制一份出来才行
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics