awakeFromNib message is sent to all nib-instantiated objects just after they are instantiated by the loading of the nib:
- (void) awakeFromNib {
[super awakeFromNib];
self.backgroundColor = [UIColor redColor];
}
Note:
If you’re an experienced OS X programmer, you may be accustomed to rarely or never calling super from awakeFromNib; doing so used to raise an exception, in fact. In iOS, you must always call super in awakeFromNib. Another major difference is that in OS X, a nib owner’s awakeFromNib is called when the nib loads, so it’s possible for an object to be sent awakeFromNib multiple times; in iOS, awakeFromNib is sent to an object only once, namely when that object is itself instantiated from a nib.