views:

24

answers:

1

In previous applications I have customised my tabBarItems by overriding init (see below)

- (id)init {
    self = [super init];
    if(self) {
        UITabBarItem *tabBarItem = [self tabBarItem];
        [tabBarItem setTitle:@"ONE"];
    }
    return self;
}

After looking at the Xcode templates I am now thinking that I would be better to add this customisation to initWithNibName:bundle: instead.

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
        UITabBarItem *tabBarItem = [self tabBarItem];
        [tabBarItem setTitle:@"ONE"];
    }
    return self;
}

does this make sense, it seems like it does to me, but I just wanted to check?

Gary

+1  A: 

It depends on whether you load your controller from a Nib (xib) file or not (and so you do all the work programmatically in the init) I guess

rano
Thats what I was thinking, much appreciate, I just wanted to get a 2nd opinion to make sure I was on the right track.
fuzzygoat