IOS - Mapkit crash - Is it a bug in xcode 4.2 and Automatic Reference Counting (ARC)?

戏子无情 提交于 2019-12-12 02:40:00

问题


I have found a very wierd problem in MKMapView that i think might be a bug in the new xcode 4.2 and ARC (Automatic Reference Count).

I created a very basic UIViewController class: MapViewController, that implements the protocol :

#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#import <CoreLocation/CoreLocation.h>
@interface MapViewController : UIViewController <MKMapViewDelegate>
@property (strong, nonatomic) IBOutlet MKMapView *mapView;

I use a xib file to instantiate the mapview and link to its delegate i.e First Responder.

Nothing is added to the m file, except the autogenerated methods inherited by UIViewController.

The MapViewController is instantiated like:

MapViewController *mapView = [[MapViewController alloc]init];
[self.view addSubview:mapView.view];

So the program crash when the mapview is loaded and you scroll the map or zoom in/out. Main will crash with a EXE_BAD_ACCESS, meaning it is accessing illegal memory.

I Profiled it with instruments and checked for Zombies, and it turns out that the mapview overreleases an object and it crashes - as seen in the img.

Zombie log http://dl.dropbox.com/u/2250562/xcode4.2-Mapview-Crash.png ![The Zombie log][1]

I do not think i do something wrong, so i would like to know if any of you might have a solution idea or want to test if you can reproduce the same result. My next step would be to test in a new project without ARC to see if that changes the problem.

System info: Xcode 4.2 Build 4D199 using ARC -> Automatic reference counting

App tested in Simulator for IOS 4.3


回答1:


Works flawlessly for me. Did you link the MapKit.framework to your target?



来源:https://stackoverflow.com/questions/7896701/ios-mapkit-crash-is-it-a-bug-in-xcode-4-2-and-automatic-reference-counting

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