Search code examples
iosdeallocunwind-segue

unwind segue and dealloc


I am trying to understand unwind segue process.

Is dealloc method of the source view controller called when unwind segue performed like UINavigationController back button process?

If not, does that mean a memory leak?


Solution

  • Not directly. It will be called when all strong references to the view controller are relinquished. After unwind is called, the uinavigation controller SHOULD be finished with the view controller, as long as you haven't retained it strongly in some sort of navigation controller or something.

    It doesn't always happen right away, think autorelease pools too. Ensure you do not have any strong delegate outlets either. (big culplrit)

    A useful tip is to look for anywhere in the view controller's code 'self' is used, and determine if it is strong, if it is you must nil it in unwind or dealloc will not get called - you shouldn't have to worry about dealloc too much with ARC - unless you have some objects you need to manage or non auto-nil weak references.