4

In Swift ARC is calling deinit when any UIViewController is removing from memory , but it's not getting called if any UIView is removed from memory.

for example

In case of UIViewController Class deinit is working great

class MusicPlayerUIViewController: UIViewController,UITableViewDelegate,UITableViewDataSource
    {
    deinit
        {
            APP_DELEGATE.RemovePlayerContents()
        }
    }

but in case of UIView Class deinit not working

class MusicPlayerView: UIView,UITableViewDelegate,UITableViewDataSource
{
deinit
    {
        APP_DELEGATE.RemovePlayerContents()
    }
}

any idea .

Anupam Mishra
  • 3,408
  • 5
  • 35
  • 63

1 Answers1

8

Parent ViewController can hold you UIView. You have to set to nil a property, that stored you UIView in parent UIViewController for release uiview.

Or override removeFromSuperview() and place your deinit code in it.

Igor
  • 12,165
  • 4
  • 57
  • 73