Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Some NSController questions...

Some NSController questions...
Thread Tools
Professional Poster
Join Date: Sep 2000
Location: San Francisco
Status: Offline
Reply With Quote
Oct 28, 2003, 08:08 PM
 
I've been trying to figure out the NSController classes with the sparse documentation provided by Apple and I have basically hit a wall.

How do you get access to the array of objects NSArrayController creates? For instance, I have a table view that I have hooked up to an NSArrayController. I put in the Object Class Name for the object I want controlled and it dutifully creates an array of these objects that then interact beautifully with my table view. My question is how do I get programmatic access to this array to either add another instance to it (say via drag and drop) or, most puzzling, to save it?

Rather than using an NSArrayController should I use an NSObjectController and set the Content to an array that I set up programmatically in my own controller class?

I'm a little confused about how to integrate these into apps a bit more complicated than the currency converter examples provided by Apple, so ANY advice would be great.

Also, now that Panther has shipped can the rest of us get access to the WWDC sessions? I noticed that there were a few related to this topic.

kman
     
kman42  (op)
Professional Poster
Join Date: Sep 2000
Location: San Francisco
Status: Offline
Reply With Quote
Oct 28, 2003, 08:48 PM
 
So in IB we have instances of these Controllers, but I don't know how to interact with them from one of my own custom classes. Do we refer to them as IBOutlets?

kman
     
kman42  (op)
Professional Poster
Join Date: Sep 2000
Location: San Francisco
Status: Offline
Reply With Quote
Oct 28, 2003, 08:52 PM
 
Originally posted by kman42:
So in IB we have instances of these Controllers, but I don't know how to interact with them from one of my own custom classes. Do we refer to them as IBOutlets?

kman
Okay, answered my own question. You do refer to it as an IBOutlet and you make a connection to it in IB and then just deal with it as any other instantiated class. Why did this seem so unintuitive? Hmm...

kman
     
Fresh-Faced Recruit
Join Date: Aug 2001
Location: Germany
Status: Offline
Reply With Quote
Nov 16, 2003, 05:19 PM
 
I've just installed XCode and the NSArrayController looks really nice ;-))

I know I need to create an IBOutlet and write my Code to fill the Array:

For example:

public void InsertARow (Object sender) {
myArrayController.addObject ...

}

Could someone gives me some samplecode on how to add the following row:
"123"; "Test"


And does anybody know how I can initialize the NSArrayController with my Array at startup?


Thanks in advance

Mark
     
Mac Enthusiast
Join Date: Feb 2001
Status: Offline
Reply With Quote
Nov 20, 2003, 10:33 AM
 
From my understanding of them... You shouldn't *add* items to an NSArrayController. Instead you should BIND (you can do this directly inside IB) an NSArrayController to an NSArray that already exists in your Application.

In short, I think of an ArrayController as a 'middleman' that is knows about both the DATA (in this case an NSArray that holds the values) as well as the controls (in say a window).

So for example:

Imagine an NSTableView with 5 columns that are bound to an NSArrayController which in turn is bound to an Array of dictionarys (defined in the source code of the app).

So if the NSTableView gets displayed it asks the NSArrayController 'give me the data' then the NSArrayController in turn looks to the Array itself for the data.

Again this is just my understanding of the way things work... I'm pretty sure other 'stuff' is going on too but I hope this helps a little (and is mostly right).

Dave
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 07:20 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2