Petravd1994
Petravd1994

Reputation: 903

How do I remove a view controller from the memory?

I am using segues to present a new view controller. I have a 1 button that goes to VC 2. I am using this code:

func jumpToVC() {
    dispatch_async(dispatch_get_main_queue()) {
        [unowned self] in
        self.performSegueWithIdentifier("whatVC", sender: self)
    }
}

However the VC will not remove itself from the memory. How can I achieve this? I am presenting my views modally.

Upvotes: 2

Views: 919

Answers (1)

bujol
bujol

Reputation: 11

I think that you got a little bit lost here. What you want is a segue that will cause you to change UIViewController object to another one. You don't need to delete the first UIViewController and it's against practice in Swift.

From what I guess, you're just starting your journey with Swift and I know how confusing it might be. Therefore, I recommend you try this tutorial: https://itunes.apple.com/us/course/developing-ios-9-apps-swift/id1104579961

I've recently learnt from that and it's the best thing I've found.

Let me know if you have any more questions and whether I can help you somehow.

Upvotes: 1

Related Questions