When working in interface builder you can layout your interface with different types of objects but I'm unclear as to whether these are instances of objects or some sort of factory method or something like that. Basically if you use Interface builder to layout your objects, especially with subclasses of uiview, how do you refer to a specific instances/objects in your code?
views:
106answers:
2You can draw connections between objects in the nib to give those objects references to each other, and you can also draw connections from the file's owner (which will be some pre-existing object from before the nib is loaded, such as a UIViewController). Generally, you'll need to structure your code so that everything that needs to access things in the nib either knows the owning object or is known by the owning object.
On the other hand, there shouldn't be that many outside objects that need to know about the specific elements in your nib or you might have a bit too much coupling.
When you place any objects such as UIButton via Interface Builder, these objects are instantiated when a xib file which you place the object is loaded.
You can refer to the object, if you hook it to a instance variable which is defined in a header file via Interface Builder.
But you need to define the instance variable to be displayed in Interface Builder like as follows.
@interface FooObject : NSObject {
UIButton *button;
}
@property (nonatomic, retain) IBOutlet UIButton * button;