Talk About Network

Google





Mac > Mac Programmer Help > Manipulating an...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 3714 of 3889
Post > Topic >>

Manipulating an NSArrayController

by Cory <cory.imdieke@[EMAIL PROTECTED] > Apr 19, 2008 at 10:41 PM

Alright, so I have a question on the best way to achieve this. I
realize there are probably many ways (as were pointed out to me
already) but I'm not sure which is the best way to do it, or perhaps
the easiest way. Here's what I've got:

I have an application that keeps track of many objects that I've
created. The main nib window has a NSTableView to show all the
objects, and on the right is an area for all the information on that
object to be displayed. There are add and remove buttons on the
bottom, and when the user clicks the add button a new nib file window
appears asking about the object to be added. Once all the information
is filled in, the user clicks OK and the new object is added to the
ArrayController in the main nib. I have some of this working and some
not.

I have the ArrayController in the main nib file, and the table shows
all the objects in the array. I have an AppController.m that I created
to manage all the things my application would be calling. When the
user clicks the add button, this is called from the AppController

- (IBAction)addButton:(id)sender {
	// Init and set window NIB
	addWindow = [[AddWindowController
alloc]initWithWindowNibName:@[EMAIL PROTECTED]
"AddWindow"];
	// Open window
	[addWindow window];
}

In the AddWindow, I have an instance of my object with all the fields
mapped to it. I tried writing another method in my AppController to be
called when the user is done to add the new object to my
ArrayController in the first nib, but I had to instantiate a new
AppController that didn't know about the ArrayController in the other
nib, because it belonged to the new nib. From the way it sounds, I can
use the File's Owner in the new nib file because the AppController
owns the second nib to call the method, and because the AppController
belongs to the first nib I can connect them this way. Does that make
sense? Is that the correct way of doing things, or is that something
that just happens to work that shouldn't be done?

Also, when my new window is brought up it appears on top, but the
first window still has focus. How can I force the focus to show up on
the first text field in the new window?

The last thing (well, for now) that I'll need help with is saving this
list of objects to a file on close and loading them next time the
application is opened. What would I do to save this, and where would
it be stored?

Thanks!
Cory
 




 3 Posts in Topic:
Manipulating an NSArrayController
Cory <cory.imdieke@[EM  2008-04-19 22:41:30 
Re: Manipulating an NSArrayController
Cory <cory.imdieke@[EM  2008-04-23 19:31:23 
Re: Manipulating an NSArrayController
David Phillip Oster <o  2008-04-25 20:28:31 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
localhost-V2008-12-19 Wed Jan 7 19:42:34 PST 2009.