ios - Is there a better way to use handler in UIAlertController (Swift)? -
i'm trying use alertcontroller allow user return main menu, if calculated value exceeded. know using simple segue lead memory problems. there way use poptorootviewcontroller method in situation instead of using segue? compiler yells @ me (no doubt reasons), gives me no useful suggestions. know problem stems handler abort fit action. can point me in right direction?
override func viewdidload() { super.viewdidload() if deltak > 2.25 { var helpalert = uialertcontroller(title: "stop!", message: "due high toricity, fit should aborted.", preferredstyle: .alert) helpalert.addaction(uialertaction(title: "abort fit", style: uialertactionstyle.default, handler: { action in self.navigationcontroller.poptorootviewcontrolleranimated(true)) }) helpalert.addaction(uialertaction(title: "continue", style: uialertactionstyle.default, handler: nil)) self.presentviewcontroller(helpalert, animated: true, completion: nil) }
you want add [weak self]
start of each handler block if referencing self
in closure.
Comments
Post a Comment