I'm using a UISplitViewController
every time I click on a row in the Master VC I can see that viewDidLoad()
is run in the Detail VC.
Does this mean i'm creating a new instance of Detail VC each row click?
If so, how can I check that the Detail VC are unloading correctly and that i'm not just creating more and more new Detail VCs?
I'm a bit lost here in Swift. Previously I could NSLog in dealloc() and see the UIViewController
correctly unloading.
I here Swift has a deinit function but this is never called:
deinit {
println("\(__FILE__.lastPathComponent)) : \(__FUNCTION__)")
NSNotificationCenter.defaultCenter().removeObserver(self)
}
1) Where should I be removing my observers?
2) When I look in the Debug Navigator in Xcode the Memory usage just keeps going up and never down.
Updated: Detail VC is being called as follows:
if segue.identifier == "addEvent" {
if let controller = (segue.destinationViewController as UINavigationController).topViewController as? ManageViewController {
controller.manageEvent = nil
controller.navigationItem.leftBarButtonItem = self.splitViewController?.displayModeButtonItem()
controller.navigationItem.leftItemsSupplementBackButton = true
}
}
I'm not doing anything different than lots of examples i've seen, but I am worried about deinit
not being called
Updated: Working now - Problem was with delegate stopping deinit
being called (see below answer)
My original Non-Working code was:
protocol ManageViewDelegate {
func pressedButton(sender: AnyObject)
}
class ManageView: UIView {
var delegate: ManageViewDelegate? = nil
...
}
New Working code:
protocol ManageViewDelegate: class {
func pressedButton(sender: AnyObject)
}
class ManageView: UIView {
weak var delegate: ManageViewDelegate? = nil
...
}