Instruments 显示了由于简单地打开和关闭警报控制器而导致的内存泄漏。
@IBAction func delBtnAc(sender: AnyObject) {
let deleteAlert = UIAlertController(title: "Delete Image?", message: "", preferredStyle: .Alert)
let cancelIt = UIAlertAction(title: "Cancel", style: .Cancel, handler: nil)
deleteAlert.addAction(cancelIt)
presentViewController(deleteAlert, animated: true, completion: nil)
}
Run Code Online (Sandbox Code Playgroud)
我已将警报减少为仅用于测试的取消按钮。
编辑:在关闭中删除了 deleteAlert.dismissViewController。修复了保留周期,但仍显示内存泄漏。也许是一个错误。
@IBAction func unwindOtherVw (seque: UIStoryboardSegue) {
println("the objectfromOtherView is \(objectFromOtherView!)")
}
Run Code Online (Sandbox Code Playgroud)
我正在使用prepareForSeque方法从其他ViewController传递一个对象(NSManaged),并在故事板中退出以及目标控制器中的上述代码.一切正常,但我如何在展开segue中添加一个标识符,以便prepareForSegue可以使用ifseque.indentifier == ______