Re: NSArrayController and the ContentArray Binding
Re: NSArrayController and the ContentArray Binding
- Subject: Re: NSArrayController and the ContentArray Binding
- From: Alex Clarke <email@hidden>
- Date: Tue, 12 Oct 2004 17:55:27 +1000
- Organization: PowerMax Computers
Scott Stevenson has a very useful technique that you should check out:
http://www.cocoadevcentral.com/articles/000080.php
and of course, mmalc's bindings for every occasion:
http://homepage.mac.com/mmalc/CocoaExamples/controllers.html
A
On Sun, 10 Oct 2004 13:55:06 +0100, Paul Sargent wrote:
>
I've reached an impasse while trying to follow the Master-Detail
>
bindings tutorial (on my machine at
>
file:///Developer/ADC Reference Library/documentation/Cocoa/Conceptual/CocoaBindings/index.html#//apple_ref/doc/uid/10000167i).
>
The Currency Converter example was fine (as it always is), but this
>
one is flooring me. I hope someone can lend me a hand.
>
>
Everything is great up until I hit the "Binding Models to
>
Controllers" section, where it says this:
>
>
--------------------------------------------------
>
You specify the content of an array controller by configuring its
>
contentArray binding. For example, assuming the File’s Owner
>
maintains a collection of Media objects called mediaAssets, you would
>
configure the contentArray binding as follows:
>
>
1. Set the Bind to aspect to the object that maintains the collection
>
of model objects (for example, the File’s Owner).
>
2. Leave the Controller Key blank.
>
3. Set the Model Key Path to the name of the array (for example,
>
mediaAssets).
>
--------------------------------------------------
>
>
It then shows a picture of the inspector panel showing this set-up on
>
the NSArrayController. Thing is their app is a Multi-Document
>
Application, and mine is a single window. What this means is that for
>
them, File's Owner is a subclass of NSDocument, for me it's
>
NSApplication.
>
>
Now I would assume that in a MDA, you would subclass NSDocument, add
>
a instance variable something like:
>
>
@interface {
>
NSMutableArray * controlledArray;
>
}
>
>
pop that into IB, and all is great. I haven't tried that, because I'm
>
not that comfortable with MDA's yet, but it would seem to make sense.
>
>
So the options I have under the "Bind to" aspect are either 'File's
>
Owner (NSApplication)' or 'User Preferences'. I know I don't want
>
user preferences, so I go with File's Owner. Now I've tried
>
instantiating an array either directly into the NIB, or into my own
>
model class which is then instantiated in the NIB, but I when I run
>
the program I get :
>
>
An uncaught exception was raised
>
[<NSApplication 0x5264f0> valueForUndefinedKey:]: this class is not
>
key value coding-compliant for the key ExposureArray.
>
*** Uncaught exception: <NSUnknownKeyException> [<NSApplication
>
0x5264f0> valueForUndefinedKey:]: this class is not key value
>
coding-compliant for the key ExposureArray.
>
>
...which I expect means that I haven't instantiated the Array in the
>
right place for the binding to attach properly (because a simple
>
NSArray would be KVC compliant, right?)
>
>
So I think my question is (but maybe my understanding of everything
>
is incorrect), how do I either:
>
a) specify a class which is instantiated in the NIB to the
>
contentArray binding? (i.e. what would it's class path be from
>
NSApplication)
>
b) specify some class other than File's Owner from the binding
>
inspector panel?
>
c) add the instance to the NSApplication class? (I would assume
>
sub-classing it, but then I need to inform IB to use the subclass.
>
How?)
>
>
Any help GREATLY appreciated.
>
>
Paul _______________________________________________
>
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
---- ----- ---- ----- ---- ----- ---- ----- ---- -----
Alex Clarke
Designer | Technician
PowerMax Computers | Lismore
Apple Certified Desktop Technician
ABN: 73 817 650 349
16 Allen St Lismore NSW 2480 Australia
Ph: 0266 224 996
M: 0413119455
email@hidden
_______________________________________________
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