views:

25

answers:

2

Hi,

I got a MainViewController who has addes a SubViewController.

In the SubViewController there another SubSubViewController who has image inside witch will be clicked sometimes.

When touchesBegan dispatch the delegate of SubSubViewController is getting called.

Now i need this.

[mainViewController method] inside the SubSubViewController. How do i connect to this parent?

Any help would be really nice!!

Michiel

A: 

Hello

The best way is to use your AppDelegate.

[ (AppDelegate*)[ [ UIApplication sharedApplication ] delegate ] doSomething ];

Good Luck ! Vincent

Vinzius
A: 

You could do: [[subsubView superview] superview] to get a reference to your mainview. Or you could use a subclass for your subsubview and give it a property and set it to keep a reference to its super-viewcontroller upon creation.

Edit: Forget about superview, it works only for views, you're interested in viewcontrollers. Sorry I got you wrong. Try keeping a reference, besides using a property in the VC itself, you could store it in the appdelegate or another singleton to make it easy to access.

Toastor