Re: Subclassing NSArrayController arrangeObjects
Re: Subclassing NSArrayController arrangeObjects
- Subject: Re: Subclassing NSArrayController arrangeObjects
- From: Gabriele de Simone <email@hidden>
- Date: Thu, 20 May 2004 10:14:25 -0400
On May 20, 2004, at 2:36 AM, mmalcolm crawford wrote:
If the 'count' of the array you've bound to is 0, it would seem
reasonable not to bother arranging the objects, since there aren't
any...
Aaah. This sounds extremely reasonable and obvious, but for my own
selfish purposes I was assuming arrangeObjects to be called at all
times :-)
I am adding elements to the "base" controller. Adding elements to the
next controller up in the chain ("plusTwo") will cause a failure (it
probably fails for the same reason insertions fail when filtering,
but I don't care about solving that problem here).
I have tried overriding countOfArrangedObjects for the "plusTwo"
controller but that doesn't do it. Neither does a reloadData on the
table view.
Have you implemented any other of the indexed accessors, like
objectInArrangedObjectsAtIndex:?
<http://developer.apple.com/documentation/Cocoa/Conceptual/
KeyValueCoding/Concepts/AccessorConventions.html#//apple_ref/doc/uid/
20002174/BAJEDEFB>
Well I have read the documentation, but if I am subclassing
NSArrayController why should I bother implementing
objectInArrangedObjectsAtIndex? It's the first time I hear that if you
subclass NSArrayController w/o adding any new keys then you need to
provide KV accessors. I was overriding countOf simply in the hope of
fooling the caller that there are always at least 2 items...
If you're altering values, it would also seem better to implement and
bind to something other than arrangedObjects -- on which other
features might depend...
- (unsigned int) countOfFakeArrangedObjects;
- (id) objectInFakeArrangedObjectsAtIndex: (unsigned int)index;
Unfortunately this is one approach I took earlier on to provide
filtering (see my prev questions on this list), but there are odd cases
where adding "fakeArrangedObjects" to an NSArrayController causes
problems in NSTableView, *if* you are using fakeArrangedObjects to
populate popup button cells (i.e. you are using some other array
controller for the table items, and then using our array controller
with fakeArrangedObjects to populate the menu). This bug caused the
popup menu to be populated with the now infamous -description's from
the proxy objects: <Class 0xADDRESS> instead of actual values.
Unfortunately my day job involves Carbon and Win32 (pfum) so it will
take me a bit to file a reproducible bug with sample code - assuming
that it's not my own ;-)
Thanks
Gabe
_______________________________________________
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.