0

I'm doing a iPhone app.

I created my own SwitchViewController Class (linked to the App-Delegate) which actually just changes the various other Views / ViewControllers (e.g ViewA, ViewB) while the app is running.

When I know recieve a tap-gesture in the ViewController-A I would like to trigger a method (eg. switchViews:(id)sender) in the SwitchViewController Class.

What would the best way to do this? Must I initiate ViewA with a object-reference to SwitchViewController? Delegate? What would be the best way?

When I add a button to ViewA its no problem, then I just can connect it to the IBOutlet. But programmatically?

Thanks, Stefan

Peter Hosey
  • 95,783
  • 15
  • 211
  • 370
Stef
  • 593
  • 3
  • 10
  • 23

2 Answers2

2

Sounds like a prime example for using the NSNotificationCenter.

Community
  • 1
  • 1
DarkDust
  • 90,870
  • 19
  • 190
  • 224
0

Used actually the responder chain, and recieved the tap in the switchViewController.

Stef
  • 593
  • 3
  • 10
  • 23