prostock
prostock

Reputation: 9545

calling initialization code on view which was created by loading nib from file

I loaded a view created by interface builder as follows:

NSArray *array = [[NSBundle mainBundle] loadNibNamed:@"MyView" owner:self options:nil];
MyView *myView = [array objectAtIndex:0];

The view created in the nib also has a .h and .m UIView subclass associated with it. I have initialization code within my .m source file. What is the preferred method to call initialization code?

Upvotes: 0

Views: 132

Answers (1)

futureelite7
futureelite7

Reputation: 11502

use -awakeFromNib. This will be called the first time the class is deserialized from the nib.

Upvotes: 1

Related Questions