Ok ..got it now.
Yes, you must know the address of the instance of myView, not the class name. However the view object you create (actually specify to be created) in IB is just that: It's an instance of myView, just as the view controller object created in IB is an instance of UIViewController (or myViewController). So the question you want to ask is: +Where does the address of these IB-created objects show up in my code?+
This is an excellent question, one which most beginners never ask because the templates and sample code often seem to have variables magically pre-loaded with the addresses of the corresponding view objects.
The answer to the general question is usually one of these two:
1) As you've seen, you can specify some of the instance variables in a custom class (such as your controller class) as
IBOutlet. This is a flag that tells IB that those vars want to be set to the address of a UI object. So IB provides Outlet connections for those vars whenever you create an instance of that custom class. You can then "connect" the Outlets to the objects. This "connection" in IB causes an instance var to be set to the address of the corresponding IB outlet when the nib is "awakened", i.e. unarchived so that the object specifications become real allocated objects in memory.
2) Connections to nib-created objects can be made in code. This commonly happens when you have a statement like:
MyViewController *myController = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil];
The above creates all the objects specified in MyViewController.xib, then makes all connections specified in the nib, and finally sets the myController var to the address of the "File's Owner", which should represent an instance of MyViewController.
If MyViewController.xib was put together correctly, you can now obtain the addresses of all its objects by climbing down the tree from the File's Owner.
For example the myController's view should have been connected to the 'view' outlet of the File's Owner, so the address of that view is now [myController view] or myController.view if view is a @property (which it is).
Then what would be the address of that view from inside one of the controller's methods? Answer: self.view.
how would I call setNeedsDisplay on the view
From inside a method of myController:
[self.view setNeedsDisplay];
Hope that helps!
- Ray