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