当我检查我的应用程序是否有内存泄漏时,我在调用此函数时发现内存泄漏
class func displayAlertWithTitle(title: String, message: String, onView view: UIViewController?) {
let alertController = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.Alert)
let defaultAction = UIAlertAction(title: "OK", style: .Default, handler: nil)
alertController.addAction(defaultAction)
if let parentView = view as UIViewController? {
parentView.presentViewController(alertController, animated: true, completion: nil)
}
}
更具体地说是parentView.presentViewController(alertController, animated: true, completion: nil)
任何人都可以解释一下,为什么会发生这种情况?