I’m new in the forum and I’d like to start by thanking the authors and the users: these pages are a precious resource for anyone who’s walking his way through the manual pages.
I am struggling a bit with the new Xcode 4.2 as I decided to stick to the new version and iOS5, which implies different project templates and the use of ARC: still, it is doable…
Here is my question: I would have expect the MapKit object (referenced by the variable ‘worldView’ in the text) to be allocated and initialized in the bviewDidLoad method[/b] (for whom is coding in the ViewController - Xcode 4.2 -) or in application:didFinishLaunchingWithOptions: (for the ones who are writing in the AppDelegate file), as it happens for the locationManager. Something like:
[i] locationManager = [[CLLocationManager alloc]init];
[b]worldMap = [[MKMapView alloc]init];[/b] [locationManager setDistanceFilter:kCLDistanceFilterNone];[/i]
If you try to allocate it as I did in the code above, the resulting map on the screen will always be centered on a fixed place regardless of the user location.
Without the memory allocation, the applications starts and locates the exact point of myIphone (I also discovered that it only works on the device, if I try the iPhone 5.0 simulator
it wouldn’t localize my position correctly).
Why are we avoiding to allocate the MapView instead of thinking along the line of the locationManager?
Thanks in advance