Re: NSArrayController and bindings
Re: NSArrayController and bindings
- Subject: Re: NSArrayController and bindings
- From: mmalcolm crawford <email@hidden>
- Date: Tue, 24 Feb 2004 13:25:49 -0800
On Feb 24, 2004, at 12:49 PM, Rob Borsuk wrote:
On Feb 24, 2004, at 3:29 PM, mmalcolm crawford wrote:
I would like to be able to count the dictionary objects but it
doesn't seem that NSArrayController (though using 'Array' in the
name) has a 'count' method.
Use the array operator @count.
When I assign the arraycontroller to an IBOutlet and then do a count I
get:
-[NSArrayController count]: selector not recognized
The array controller is still a controller -- it manages the array.
You would use:
[[NSArrayController content] count]
Better, if all you want to do is display the count, then bind the
textfield's value to the array controller's 'arrangedObjects' with
Model Key Path '@count'.
I would like to be able to write the "array" out as a text file
(viola - plist) but it seems that it likes to save as a encoded
format.
In the most likely scenario, the NSController is simply managing the
*display* of the array, the array itself is still managed by a
classic custom "controller" which should be responsible for saving
and loading...
So would I subclass Arraycontroller versus binding to a NSDocument to
gain this functionality?
You will probably subclass NSArrayController to provide custom
behaviour that applies directly to the array the controller is managing
-- such as sorting, filtering etc. Your application as a whole is
likely to have an "app controller" that is responsible for managing the
data structures. It may be a subclass of NSObject. See:
<
http://homepage.mac.com/mmalc/CocoaExamples/Combatants.zip>
for an example.
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.