Why am I crashing after MKMapView is freed if I'm no longer using it?

后端 未结 4 543
误落风尘
误落风尘 2020-12-02 15:00

I have a MKMapView. Sometimes after my view controller is dismissed, I\'ll get a EXC_BAD_ACCESS.

I turned on NSSZombies and it

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-02 15:40

    OK, this is the confirmation of the answer. It's from the Apple doc, but it's missing from MKMapView. It's only found under the documentation for its delegate protocol:

    Before releasing an MKMapView object for which you have set a delegate, remember to set that object’s delegate property to nil. One place you can do this is in the dealloc method where you dispose of the map view.

    NOTE: This also applies to UIWebView.

    I set the MapView's delegate pointer to nil in the delegate's dealloc method, and our crashes seem to have been eliminated.

提交回复
热议问题