I just finished my first app. I was about to submit it when I figured out a (10MB) memory leak. According to this post it is caused by the segues I am using.
As I understand it, currently my app generates a new view every time I perform a segue. I have been reading a lot of posts that ended up confusing me. Should I use dissmissViewController? Unwind Segue?
This post was really helpful regarding unwind segue. But on a UI point of view, I like the current performSegueWithIdentifier solution as I have made nice horizontal sliding segues. Is there a way to customize transition when using an unwind segue?
I wish there was a possibility to simply "kill" the previous ViewController in the custom segue code...
ps: Here is the code of one of the segue:
import UIKit
class FirstCustomSegueUnwind: UIStoryboardSegue {
override func perform() {
var firstVCView = self.sourceViewController.view as UIView!
var secondVCView = self.destinationViewController.view as UIView!
let screenWidth = UIScreen.mainScreen().bounds.size.width
let screenHeight = UIScreen.mainScreen().bounds.size.height
secondVCView.frame = CGRectMake(-screenWidth, 0.0, screenWidth, screenHeight)
let window = UIApplication.sharedApplication().keyWindow
window?.insertSubview(secondVCView, aboveSubview: firstVCView)
UIView.animateWithDuration(0.4, animations: { () -> Void in
firstVCView.frame = CGRectOffset(firstVCView.frame, screenWidth, 0.0)
secondVCView.frame = CGRectOffset(secondVCView.frame, screenWidth, 0.0)
}) { (Finished) -> Void in
self.sourceViewController.presentViewController(self.destinationViewController as! UIViewController, animated: false, completion: nil)
}
}
}