Re: Bindings between nib files? <!solved>
Re: Bindings between nib files? <!solved>
- Subject: Re: Bindings between nib files? <!solved>
- From: Michael Carter <email@hidden>
- Date: Mon, 02 May 2005 13:37:56 -0700
- Newsgroups: apple.lists.cocoa-dev
- Organization: Apple
- Xref: news.apple.com apple.lists.cocoa-dev:91567
Okay, maybe not solved. I'm still having trouble with bindings after all.
Perhaps it's the way I've designed the objects...
AppController object:
---------------------
NSMutableArray *emps; // where the global list of employees is
NSWindowController *empPanelController; // ref to separate Nib file
where user edits/add employees.
>From empPanelController's Nib file:
-File's Owner: NSWindowController (the ivar in AppController)
-Panel: the panel with the master-detail interface for employee objects
-EmployeeController: the NSArrayController that binds everything
So, when I run the panel, create/edit employees works fine. However, all
the employees I create/edit are being stored locally(?) in the panel?
I'd like the panel to edit/create employees right to/from the
NSMutableArray in the AppController. Doesn't look like I can connect the
NSArrayController's contentArray to the emps array at all, which is what
I thought I need to do.
Do I have to change the way I've coded this? Perhaps make a class object
for the employee editor panel that has an NSMutableArray of it's own
that I can point to the master *emps array? Or perhaps I can make the
bindings from the AppController programatically somehow (even though I
would rather do it properly--i.e. be able to express that through IB's
GUI)? Should I instead move the *emps employee array directly to the App
itself? Perhaps instead I need to subclass AppController from
NSWindowController so it can be the File's Owner of the nib!? ACK!
:P
Thanks in advance for any input! :)
In article <email@hidden>,
Michael Carter <email@hidden> wrote:
> In article <email@hidden>,
> Michael Carter <email@hidden> wrote:
>
> Wow...okay. Just figured this out thanks to a great article from Scott
> Stevenson on cocoadevcentral.com! so THAT'S what an NSObjectController
> is! It's a bridge between the code in AppController.m and the bindings
> system. That certainly clears up a lot. :)
>
>
> > Hello all.
> >
> > I'm writing a Cocoa app (non-Document) in which I'll be maintaining a
> > list of Employee objects which will be associated later to a task
> > object. In order to add/edit employees I decided to create a separate
> > nib file. There is an array in my app controller that contains Employee
> > objects. This separate nib has a table view on the left where I show all
> > the employee objects in the array. Selecting a name on the left will
> > display details on the right, which has 8 NSTextFields to hold the data
> > which pertains to the employee.
> >
> > So far I've set up bindings between the master-detail views in the nib.
> > I've also set up an NSArrayController which points to the Employee class
> > object. my app controller object has an instance variable of type
> > NSWindowController which I use to reference the employee panel:
> >
> > @interface AppController : NSObject
> > {
> > // model
> > NSMutableArray *routeList; // array of routes
> > NSMutableArray *emps; // array of employees
> > NSMutableArray *categories; // array of categories
> >
> > // view
> > NSWindowController *empPanelController; // employee panel
> > }
> > - (IBAction) showEmpPanel:(id)sender;
> > [...]
> > @end
> >
> > The nib's File's Owner is set to NSWindowController, and i instantiate
> > the ivar when showEmpPanel: is sent from a menu item. The panel shows up
> > fine when I compile and run the app, and I can add and delete employees
> > via local buttons bound to the NSArrayController's add: and delete:
> > methods. However, I can't seem to connect the NSArrayController to the
> > *emps array in order to actually put the employee objects I'm creating
> > via bindings into that array! Ack!
> >
> > Connecting the NSArrayController to the File's Owner placeholder in the
> > nib would mean connecting it to the instance of NSWindowController in my
> > app controller, right? That ivar doesn't know what the *emps array is,
> > so that didn't work. The only other default options are Shared User
> > Defaults and Shared App. I can't think of any other way to connect it.
> >
> > How best would I handle communicating between the nib and the *emps
> > array in my app controller? I have a popup in my main window which I'd
> > like to have all the employees show up in. I'm having trouble binding
> > that to the *emps array as well.
> >
> > I added a button on my main window and a text field I use to query [emps
> > count] to verify how many objects actually are in that array. Nothing
> > I've done so far shows objects being added to that array. Help!
> >
> > Thanks!
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden