Re: NSArrayController population
Re: NSArrayController population
- Subject: Re: NSArrayController population
- From: Aubrey <email@hidden>
- Date: Sun, 9 Nov 2003 22:42:32 -0600
This was confusing me for a while but I figured out this today.
... and it was amazingly easy.
So, if you don't want to go to the trouble of creating a document based
app
Create a cooca application and:
in Interface Builder:
create the object
1. create a subclass of NSObject named theObject
2. create an instance of theObject
3. create the files for theObject
4. open theObject.h
5. create and instance variable: NSMutableArray * theArray;
6. save and close.
configure a controller
1. drag out a NSObjectController from the controllers pallet
2. goto the inspector ( command 1)
3. select attributes in the popup
4. add - theArray to the keys list of the Object Controller
5. select connections
6. control-drag a connection to form Object Controller to theObject
7. connect the content outlet to theObject
configure the Array Controller
1. select the Array Controller and select the Bindings Popup
2. Bind the content to your new controller and array key.
3. hook up your add and remove buttons and all the UI stuff.
this will work without even initializing the objects array. (good or
bad?)
... and it doesn't take two many more lines of code to save and restore
it's value to a plist.
On Nov 9, 2003, at 8:42 PM, mmalcolm crawford wrote:
>
On Nov 9, 2003, at 6:17 PM, Aaron Patterson wrote:
>
>
> Right now, contentArray for the NSArrayController isn't bound to
>
> anything. I'm
>
> having a tough time figuring out how to bind anything to the
>
> contentArray. What
>
> kind of objects can I bind to it? The drop down only lets me choose
>
> from
>
> "Shared User Defaults", and "File's Owner".
>
>
>
In many cases you'll bind to File's Owner. You must then bind to a
>
variable in that object which is either an array or which may be
>
accessed as an array (for which you have provided the array
>
accessors).
>
>
> Please pardon my ignorance, I'm very new at Cocoa dev. I will
>
> happily RTFM if
>
> someone can point me to documentation on dealing with controllers.
>
>
<http://developer.apple.com/documentation/Cocoa/Conceptual/
>
ControllerLayer/index.html>
>
>
The controller layer provides a layer of abstraction above the already
>
fairly well-abstracted Cocoa frameworks. It is not yet clear how
>
readily comprehensible this matter will be to novices. My gut feeling
>
(which I'm certainly willing to amend) is that, attractive though this
>
technology is, you would better served by getting to grips first with
>
"classic" Cocoa first, then progressing on to controllers later.
>
There is certainly much more material available to help newcomers
>
learn classic Cocoa...
>
>
mmalc
>
_______________________________________________
>
cocoa-dev mailing list | email@hidden
>
Help/Unsubscribe/Archives:
>
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.