viewController not being removed properly?

后端 未结 2 611
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-29 02:52

In my viewController I have an NSFetchedResultsController for populating a tableView. In the viewDidLoad() I\'m saving the current time to

相关标签:
2条回答
  • 2021-01-29 03:15

    I'm leaving the view in a seperate function like this:

    let storyboard = UIStoryboard(name: "Main", bundle: nil)
    let controller = storyboard.instantiateViewController(withIdentifier: "HomePage") as? HomeVC
    controller?.managedObjectContext = self.managedObjectContext
    self.present(controller!, animated: true, completion: nil)
    

    Yup, that's the problem. Instead of returning to the existing HomeVC, you're making a new HomeVC and presenting that on top of yourself. So you just keep piling up the view controllers.

    What you need to do to get back home is unwind what you did to get here. If present, now dismiss. If push, now pop.

    0 讨论(0)
  • 2021-01-29 03:20

    What do you mean by "leave the view" Are you going back? If you are, then deinit is not being called.

    Test it by doing the following.

    deinit {
       print("VC Should deinitialize")
    }
    

    If this isn't called when you go back, then you have a retain cycle problem.

    0 讨论(0)
提交回复
热议问题