Quote:
Originally Posted by benoitr007
Thank you very much for the replies... Unfortunately I'm still confused. Haha.
iDoTouch: Thanks, but actually I can access the viewController in the AppDelegate since it's where the instance is created. What I want is access the viewController in the view object.
Artem: The problem is the view isn't initialized programmatically (as far as I know). I have told IB that the view of my view controller should be an object from the MainView class, but that's it. Everything seems to be done in the background. So where should I put that code? I want to keep my IB-made interface.
Also nobody really answered the question number 2 of my original post.
|
What I meant to say is that if you put the following code into your MainView.m file, then that is one way to access your view controller.
Say you have a MainView and a MainViewController.
MainViewController's "view" property is of the class "MainView"
In your MainView.m file, one way to access MainViewController (ie, the MainView's controller) is to insert the following code into your MainView.m file:
So, for example, if in my MainView, I want to call a method called "mainViewControllerMethod" of the MainViewController when the touchesEnded method of MainView is called, I would insert the following into MainView.m:
- (void)touchesEnded

NSSet *)touches withEvent

UIEvent *)event
{
//Create a pointer to the delegate then access the mainViewController
MyAppDelegate *delegate=[[UIApplication sharedApplication] delegate];
[delegate.mainViewController mainViewControllerMethod];
}
Does that make more sense?