Tamarisk
Tamarisk

Reputation: 939

viewDidAppear from specific view controller

I am looking to have some code run when my view controller appears from a specific, other view controller. Something along the lines of this pseudo code:

override func viewWillAppear(animated: Bool) {

    if appearedFromVC == specificVC {
        println("appeared from specificVC")
    }
}

Upvotes: 0

Views: 104

Answers (1)

William Hu
William Hu

Reputation: 16179

You can set a BOOL value like var isFromSpecificVC: Bool for the specificVC, and in your appedaredFromVC make something like :

if speicificVC.isFromSpecificVC == true {
}

Also you can add a NSNotification in appedaredFromVC,

NSNotificationCenter.defaultCenter().addObserver(self, selector: "method:", name: "from_specific_view_controller", object: nil)

and post this notification when specificVC disappear. Good luck : )

Upvotes: 1

Related Questions