1

I'd like to use IB to create a toolbar with assorted toolbar items, but create and use this toolbar programatically - adding it to a view at my discretion, and not while initializing the view controller.

I'm pretty sure it can be done - but haven't been able to find a good reference. Any help?

Don Wilson
  • 2,303
  • 3
  • 26
  • 34

1 Answers1

3

Read about NSBundle's loadNibNamed:owner:options: method:

NSArray *objects = [[NSBundle mainBundle] loadNibNamed:@"Toolbar" owner:self options:nil];

This will return all the objects in nib which you can get using simple array methods. Also note that if nib file references any outlets to other objects in nib - they must be defined in your controller (or any other given nib owner) as well otherwise you'll get KVC exceptions.

Eimantas
  • 48,927
  • 17
  • 132
  • 168