Bijoy Thangaraj
Bijoy Thangaraj

Reputation: 5546

Determining the UIViewController from which the current UIViewController was loaded

I have a main UIViewController which has an embedded Navigation Controller. I have 2 additional UIViewControllers that are launched from the main UIViewController via push segues. When the user navigates from one of these two view controllers to the main UIViewController, I would like to identify from which UIViewController the user navigated from. How can I get this information?

Upvotes: 0

Views: 51

Answers (2)

Msencenb
Msencenb

Reputation: 5104

You can jerry rig this but the 'right' way to do this in objective-c land is to use either a delegate or NSNotificationCenter. In this particular case I think NSNotificationCenter is probably easiest... there is a great example here: Send and receive messages through NSNotificationCenter in Objective-C?

Upvotes: 0

Albara
Albara

Reputation: 1296

I can think of two ways:

1- Use delegation on the two subviewControllers, and use the main as the delegate handler.

2- Use viewWillDisappear on the two subviewControllers, and change a value on the main view controller by something like self.presentedController.yourValue

Hope this makes sense :)

Upvotes: 1

Related Questions