Hi,
I have a question regarding core data and selection.
I have followed the "CarLot" example provided in the book "Cocoa Programming for Mac OS X".
Basically I have a Window with table view, the columns of table view are binded to an array controlled, below the table view I have a date picker showing a date based on the selected row on the table view.
What I would to do now, is having the same functionality but with the date picker in another window (i.e.: another XIB and another controller).
As in the other window I would like to also other objects, I need to have the same NSArrayController in two views.
My idea was to create an init function on my second-view controller:
Code:
- (id)initWithArrayController:(NSArrayController *)aController
{
[super init];
controller = aController;
return self;
}
The first question I would like to ask, is this a correct way to proceed in order to have a controlled "shared" in two windows?
The second question is, how can I access an NSArrayController created in IB in my code?
In my .h file I currently have:
Code:
IBOutlet NSArrayController *myArrayController;
I have then bound myArrayController in IB.
And my idea was to do something like:
Code:
- (IBAction)openSecondWindow:(id)sender
{
if (!secondWindow) {
secondWindowController = [[SecondWindowController alloc] initWithArrayController: myArrayController];
}
[secondWindowController showWindow:self];
}
but myArrayController is always NULL.
What am I doing wrong? How can I access an IB drag-and-dropped control in code?
Thanks a lot!