NSArrayController - another try
NSArrayController - another try
- Subject: NSArrayController - another try
- From: Dominik Wagner <email@hidden>
- Date: Thu, 20 Nov 2003 01:20:22 +0100
Hi List,
Yesterday I started to play around with the Controller Layer, and was
overall very pleased. NSObjectController worked as described. You enter
the Keys into the Attributes section of the Interface Builder
inspector, and connect the content outlet to the corresponding KeyValue
Compliant object. Everything gets updated if something is changed. So
far so good.
Then I got to the NSArrayController. Here is where the documentation
and sample code ended. The Sample Code out there always neglects the
actual Array that the ArrayController uses. The Class you specify in
the Attributes section of the Inspector is the class of the objects
that are inside the array. The content outlet should then be set to the
actual array. As the actual array resides in some controller or model
class I presume this would best be done programmatically. If you do so
then what you have set up is the "UI" side of the controller, if you
change something in the UI then the array is updated. If you change
things via the NSArrayController methods, then the array gets changed
accordingly to. But if you change something programmatically directly
in your NSMutableArray, then nothing happens. Shouldn't the setContent:
method of the NSArrayController actually register the controller as an
Key-Value-Observer for the array? In the NSObjectController the
controller registers itself as observer with the object it controls.
This was what I expected for the NSArrayController too. But apparently
this is not done automatically.
What is done automatically is Observing the contents of the array,
which is interesting.
My question now is: "hat is the correct way, with least lines of code,
to make the NSArrayController Observe the Array? As the array gets all
the removeObject and addObject method calls it definetly should now
whats happening. So I should not actually be bothered with making my
whole model KeyValueCoding compliant. As I read through the threads on
this list I found out that the NSArrayController has a binding for the
contentArray. So somehow I should marry this with the actual
NSMutableArray in my model-object, should I?
I'm looking forward to your suggestions,
dom
--
Dominik Wagner Mail: email@hidden
TheCodingMonkeys
http://www.codingmonkeys.de/
_______________________________________________
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.