NSTableView doesn't populate with array objects until a new object is added via the controller

Posted by Luke on Stack Overflow See other posts from Stack Overflow or by Luke
Published on 2013-11-03T19:12:50Z Indexed on 2013/11/05 3:54 UTC
Read the original article Hit count: 140

I have an NSTableView and an array controller set up as shown here, using cocoa bindings: https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/TableView/PopulatingViewTablesWithBindings/PopulatingView-TablesWithBindings.html#//apple_ref/doc/uid/10000026i-CH13-SW3

In my app delegate during applicationDidFinishLaunching I have the following snippet in here, initialising the array and filling it with objects

array = [[NSMutableArray alloc] init];

SomeObject* foo = [[Object alloc] init];
foo.text = @"sup";
[array addObject:foo]; //Repeat this a few times

However, when I build the app and run it I end up with an empty table. However, if I bind a button to the array controller's add: input and click it during runtime (this adds a new object to the array and table) then the table will show the new object first, with the objects added during applicationDidFinishLaunching following it.

Why does this happen? And is there a way to make my table populate without having to add an element first?

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about arrays