I have a basic project that contains nothing but an NSForm
. All i'm trying to do is add some rows to it. From my understanding, I should be able to do this somehow like the following:
- (void) awakeFromNib
{
NSLog(@"Test: %p", form);
[form addEntry: @"Hello World 1"];
[form addEntry: @"Hello World 2"];
[form addEntry: @"Hello World 3"];
[form sizeToCells];
}
I have confirmed that my form is not null (the test print shows its address), but my form still contains nothing but the two default entries that are displayed when I drag an NSForm onto my view.
Where am I going wrong?
I've just spent a while playing about with this, and it seems the problem is doing it in awakeFromNib:
.
In a sample project, I made an outlet for the NSForm in my app delegate class. Then I pasted your code into applicationDidFinishLaunching:
. It worked (albeit with a graphical glitch in the cell that was selected by default).
If your really need the logic to go in awakeFromNib:
, could you maybe put it in its own method and call it using performSelector:afterDelay:
?