• 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: How does a binding know what it gets should be treated like an NSArray or not ? (Follow up)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How does a binding know what it gets should be treated like an NSArray or not ? (Follow up)


  • Subject: Re: How does a binding know what it gets should be treated like an NSArray or not ? (Follow up)
  • From: email@hidden
  • Date: Mon, 27 Feb 2006 09:49:30 -0800


On 2006/02/26, at 10:44, email@hidden wrote:

On 2006/02/26, at 6:06, Camillo Lugaresi wrote:

In general, it looks like you're making things harder for you than they should be. It's not obvious why you would need a custom array controller for that UI. This site has several examples of the recommended way to do things: <http://homepage.mac.com/mmalc/ CocoaExamples/controllers.html>
Yes, your right, I was definitely making it much harder than it needed to be.

In fact, one of the first places I went to for pointers was the page you just mentioned (thanks to mmalc), but couldn't find the solution to my specific problem there either.

................

So it turns out, my solution was standing in front of me the whole time. Just let the proxy be a full proxy, not just for the derived key value, but all key values of the wrapped object, and return an array of managed objects wrapped in proxies from arrangedObjects. Then I can bind the table view to all the keys from the same base key path and get the results I wanted. It works perfectly.

I just wanted to follow up on myself, and post my discovery in case any one else using self-made proxies in an NSArrayController. (Yes, all 2 of you)


If one is going to wrap individual objects contained in an NSArrayController, do not return them from -(id)arrangedObjects.
If you do, you'll lose sorting for any key-values the proxy adds to the wrapped object. Sorting is done from -(NSArray *)arrangeObjects: (NSArray *)objects.


So in arrangeObjects, you wrap each object in the "objects" array, then pass that array to super's implementation of arrangeObjects and return the array.

Like so:

-(NSArray *)arrangeObjects:(NSArray *)objects
{
	//Objects in contents are now wrapped
	NSArray *wrappedObjects = [self wrapObjectsInProxiesFromArray:objects];

//Pass to super to let it sort using keys provided by other UI elements such as NSTableColumn
return [super arrangeObjects:wrappedObjects];
}


Chiao,

Andre
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Fwd: How does a binding know what it gets should be treated like an NSArray or not ? (Was: How to observe and bind (KVO/KVB) to a value generated at runtime..) (From: email@hidden)

  • Prev by Date: Shark and function tracing objective-c methods
  • Next by Date: Re: keychain secure note
  • Previous by thread: Fwd: How does a binding know what it gets should be treated like an NSArray or not ? (Was: How to observe and bind (KVO/KVB) to a value generated at runtime..)
  • Next by thread: binding hidden for multiple selections
  • Index(es):
    • Date
    • Thread