• 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
Re: NSTableView and multiple NSArrayControllers
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTableView and multiple NSArrayControllers


  • Subject: Re: NSTableView and multiple NSArrayControllers
  • From: Gabriele de Simone <email@hidden>
  • Date: Mon, 26 Apr 2004 12:48:13 -0400

On Apr 26, 2004, at 11:45 AM, mmalcolm crawford wrote:


On Apr 26, 2004, at 6:34 AM, Gabriele de Simone wrote:
when you create a binding for a NSTableColumn, the content binding is created automatically for you for that particular tableview... but, it doesn't set the content binding through the bind: API that you use. You need to explicitly set the
Also.. I don't think you can have multiple arraycontrollers wired to a single tableview.
I am only using a second NSArrayController to populate the NSPopUpMenuCell's in a table column, as shown in one of the ubiquitous Cocoa examples. The problem is that the menu is getting populated with things like <SomeObject 0xSOMEADDR> instead of the original objects, even though the array returned to the table is valid both in content and in number of elements. My suspicion was that binding the NSTableView sortDescriptors manually to the NSArrayController was screwing things up. Is sortDescriptors also automatically bound to the array controller?

Have you established the popup's contentValues binding?

I have, and at some point, it used to work. Then I started fiddling with the NSTableView bindings (the ones that don't seem to be exposed or at least don't show up via [NSTableView exposedBindings]) and everything *stopped* working at that point.

I will abuse yours (and everyone else's) help for one more question: when using KVC to expose a variable that we want to be read-only, is it sufficient to simply not provide the setter method?

Yes. You might therefore bind your popup's contentValues to:
[ArrayController].arrangedObjects.readOnlyDescriptor

My situation is slightly different:

[ArrayController].arrangedAndFilteredObjectsReadOnly.somekey

I was hoping to use the following strategy as an alternative to filtering (for one, to avoid failed insertions with filtering on, or to have many different types of filters without crowding the arrangeObjects function):

- (NSArray*) arrangedObjectsWithFilter {
NSArray* arrangedObjs = [self arrangedObjects];
NSMutableArray* filteredObjs = [NSMutableArray arrayWithCapacity:0]; NSEnumerator* enumerator = [arrangedObjs objectEnumerator];
id item;

while (item = [enumerator nextObject]) {

if ( <passes filter> ) {
[filteredObjs addObject:item];
}

}

return filteredObjs;
}

And simply insert "arrangedObjectsWithFilter" where previously one was using "arrangedObjects". I also have a triggerValueForDependentKeys call in the +initialize method so that this new arrangedObjectsWithFilter is updated whenever one changes arrangedObjects.

More importantly, is this a good approach for this kind of filtering problems?

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.


  • Follow-Ups:
    • Re: NSTableView and multiple NSArrayControllers
      • From: Scott Anguish <email@hidden>
References: 
 >NSTableView and multiple NSArrayControllers (From: Gabriele de Simone <email@hidden>)
 >Re: NSTableView and multiple NSArrayControllers (From: Scott Anguish <email@hidden>)
 >Re: NSTableView and multiple NSArrayControllers (From: Gabriele de Simone <email@hidden>)
 >Re: NSTableView and multiple NSArrayControllers (From: mmalcolm crawford <email@hidden>)

  • Prev by Date: (no subject)
  • Next by Date: setApplicationIconImage
  • Previous by thread: Re: NSTableView and multiple NSArrayControllers
  • Next by thread: Re: NSTableView and multiple NSArrayControllers
  • Index(es):
    • Date
    • Thread