MKMapView crashing with EXC_BAD_ACCESS

不羁的心 提交于 2019-12-23 09:19:46

问题


I have the following line of code which activates the breakpoint

[mapView addAnnotations:grabinstance.itemArray];

This crashing randomly. grabinstance.itemArray is fully populated always and is never changing at the time due to this bit of code only being called once the array is full. This particular time this was confirmed as 323 items in the array.

NSZombieEnabled doesn't find anything at all either.

The backtrace is below and line 1154 is the line above.

#0  0x0126a372 in _insert ()
#1  0x0126a312 in _splitNode ()
#2  0x0126a3b7 in _insert ()
#3  0x011db253 in -[MKAnnotationContainerView addAnnotation:] ()
#4  0x011dfc2e in -[MKAnnotationContainerView addAnnotations:] ()
#5  0x011b0b30 in -[MKMapView addAnnotations:] ()
#6  0x00009257 in -[BigViewController plotItems] (self=0x614de90, _cmd=0x16464f) at /Users/zzzz/Documents/iPhone Projects/BigProject/Classes/BigViewController.m:1154
#7  0x005336c1 in _nsnote_callback ()
#8  0x01c18f99 in __CFXNotificationPost_old ()
#9  0x01b9833a in _CFXNotificationPostNotification ()
#10 0x00529266 in -[NSNotificationCenter postNotificationName:object:userInfo:] ()
#11 0x00024071 in -[ItemGrabber parserDidEndDocument:] (self=0x617b540, _cmd=0x689aa3, parser=0xf6b4ab0) at /Users/zzzz/Documents/iPhone Projects/BigProject/Classes/ItemGrabber.m:267

回答1:


You should check your annotations using CLLocationCoordinate2DIsValid():

if (CLLocationCoordinate2DIsValid(place.coordinate)) {
    [_mapView addAnnotation:place];
} else {
    NSLog(@"place %@ has invalid coordinates", place.name);
}



回答2:


Bug reported to Apple and as been acknowledged




回答3:


I also had the same problem and i fixed it,The problem was with my locations,The objects in the array may not contain valid locations,They may be garbage values



来源:https://stackoverflow.com/questions/4202510/mkmapview-crashing-with-exc-bad-access

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!