0

I have a view controller A that presents has a modal segue which presentes a UINavigationController which has as root view controller another view controller B.

How to know the class of view controller A from view controller B?

Preferably using a delegate as a last resort.

Jake Ortiz
  • 503
  • 9
  • 20

2 Answers2

0

One solution is to override UINavigationController and add a weak property for the controller A. Then you can access that property from the controller B, and get its class name.

TotoroTotoro
  • 17,524
  • 4
  • 45
  • 76
0

Try this

if ([self.navigationController.presentingViewController isKindOfClass:[ViewControllerA class]){
       //do stuff
    }
    else{
       //it's view controller b, do stuff
    }
Chris Loonam
  • 5,735
  • 6
  • 41
  • 63