views:

636

answers:

5

Hi everyone,

I'm having an issue with a MKMapView, hope someone can help me.

I have a view that embed a MKMapView and a navigationController. I push in my navigationController another viewController then another one again. Then if I go back to the MKMapView and touch the map, the application crash. so MkmapView > View2 > View3 > View2 > MKMapView > touch on the map then crash.

I definitly don't understand why. If I only push another view then come back, it works well. So: MkmapView > View2 > MKMapView = OK

I Use the other views in the same way in another part of the application without any problem. View1 > View2 > View3 > View2 > View1 = OK

I checked, no memory warning viewDidUnload or dealloc method are called.

The error is: *** -[NSURL length]: unrecognized selector sent to instance 0x4806930 This time it was an NSURL that crashed but it's almost all the time different: NSArray, NSDictionnary etc...

Here is the stack trace:

0 0x3266bdf4 in objc_exception_throw

1 0x32de2bfc in -[NSObject doesNotRecognizeSelector:]

2 0x32d67b18 in forwarding

3 0x32d5e840 in forwarding_prep_0_

4 0x32cec074 in -[MKOverlayView _annotationViewForSelectionAtPoint:avoidCurrent:]

5 0x32ce4b60 in -[MKOverlayView annotationViewForPoint:]

6 0x32cc7efc in -[MKMapView _firstTouchBegan:withEvent:]

7 0x32d17e28 in -[MKScrollView _firstTouchBegan:withEvent:]

8 0x32d17c98 in -[MKScrollView touchesBegan:withEvent:]

9 0x30c4a888 in -[UIWindow _sendTouchesForEvent:]

10 0x30c49f94 in -[UIWindow sendEvent:]

11 0x30c45790 in -[UIApplication sendEvent:]

12 0x30c45094 in _UIApplicationHandleEvent

13 0x31bba990 in PurpleEventCallback

14 0x32da452a in CFRunLoopRunSpecific

15 0x32da3c1e in CFRunLoopRunInMode

16 0x31bb9374 in GSEventRunModal

17 0x30bf3c30 in -[UIApplication _run]

18 0x30bf2230 in UIApplicationMain

19 0x000025f8 in main at main.m:14

Does anyone had same kind of issue ? Does someone could give me advices on how I could locate the bug or what I should check ?

Thanks for your time!

A: 

Try turning on zombies. What's probably happening here is that an NSURL object is being deallocated, and something else is being created at the same address.

NSResponder
A: 

Your map view has an annotation. If you set a breakpoint in your annotation's -title method you will get that same stack trace when you touch the map.

Your annotation is getting released prematurely.

Darren
A: 

can you post the complete code of your mapview class or send me the app i'll remove the error.my mail address is [email protected]

Rahul Vyas
A: 

hi, did anyone figured that out? (Rahul?)

I have a similar problem - I have a couple of tabs in my view and when the user clicks on the map view tab, then to some other tab and then back too fast (which basically destroys and re-creates the MapView each time the tab is displayed), it randomly crashes. When I do the same to the other tabs, which were written by me, it works ok - creating/destroying the views fine.

I suspect that it is because of poor memory management of the MapView control. I checked it with Instruments and it leaks memory all the time - even without my interaction. (have tried it with/without annotations too, still same problem)

I have a workaround - to keep the control in memory all the time but that's not a solution.

Any ideas?

dave
A: 

Make sure to use MKMapView.delegate=nil before u release the MKMapView object in dealloc method.This is important for iOS 3.0, not imperative in higher versions.

Ishank