I finished the RaiseMan project in Chapter 8. Decided I would like it come up initially already populated with some values (Person objects).
So in RMDocument.xib window I created a Referencing Outlet in my RMDocument.h file from the Array Controller:
@property (strong) IBOutlet NSArrayController *arrayControllerOutlet;
In RMDocument.m I first synthesized it:
Then I added this code (using the Xcode provided method) windowControllerDidLoadNib except for the very last line:
- (void)windowControllerDidLoadNib:(NSWindowController *)aController
// Add any code here that needs to be executed once the windowController has loaded the document’s window.
Person *p1 = [[Person alloc] init];
[p1 setPersonName:@“John Smith”];
Person *p2 = [[Person alloc] init];
[p2 setPersonName:@“Jane Doe”];
When I first tried it the employees didn’t show up until I added a New Person. Then I searched around and added the very last line above:
That gets the Array Controller to make the TableView display these Persons right away.
My question is, is this a reasonable thing to do, or is there something better?