• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Subclassing NSArrayController arrangeObjects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Subclassing NSArrayController arrangeObjects


  • Subject: Subclassing NSArrayController arrangeObjects
  • From: Gabriele de Simone <email@hidden>
  • Date: Wed, 19 May 2004 16:47:53 -0400

I have run into a problem with NSArrayController arrangeObjects. I am attempting to do the converse of filtering, that is: in my subclass' arrangeObjects I *add* objects rather than filter them out, like in the following code:

- (NSArray *)arrangeObjects:(NSArray *)objects {
NSMutableArray* arrangedObjects = [NSMutableArray array];

[arrangedObjects setArray:[super arrangeObjects:objects]];
[arrangedObjects insertObject:myHardCodedFirstElement
atIndex:0];
[arrangedObjects addObject:myHardCodedLastElement];

return arrangedObjects;
}

Before I delve into the problems with this strategy, let me explain that my subclass of NSArrayController has its "contentArray" binding bound to some *other* NSArrayController's arrangedObjects (something which I think it's alright to do):

MyControllerPlusTwo.arrangedObjects --bound to-->
--> BaseArrayController.arrangedObjects --bound to-->
--> SomeObject.someArray (KVC compliant)

Now, the subclass whose code I pasted above is used by an NSTableView. I would assume that the NSTableView should display at least my 2 hardcoded elements even when the "parent" NSArrayController is empty (because I am explicitly adding 2 elements). The fact is, the table view remains empty.
If I then add one element to the "base" NSArrayController, the table will suddendly display all three elements. If I remove any of these elements, it will go back to empty.

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.

Any suggestions?

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.


  • Follow-Ups:
    • Re: Subclassing NSArrayController arrangeObjects
      • From: mmalcolm crawford <email@hidden>
  • Prev by Date: Re: better image scaling?
  • Next by Date: Default Mail/Web apps
  • Previous by thread: Re: Lifetime of an NSURLHandle
  • Next by thread: Re: Subclassing NSArrayController arrangeObjects
  • Index(es):
    • Date
    • Thread