[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)

[color=red][size=medium][b]找到解决方法了


NSArray* array = [NSArray arrayWithArray:mapView.annotations];
[mapView removeAnnotations:array];
应该把数组复制一份出来才行[/b][/size][/color]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值