• 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
bindings best practices
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bindings best practices


  • Subject: bindings best practices
  • From: Derrek Leute <email@hidden>
  • Date: Sat, 28 Oct 2006 14:27:15 -0400


I have a button who's (when did buttons become who?) enabled binding is bound to selection.canAddNew of an NSTreeController. This works great.


however if I do this:

[self bind:@"testToAdd" toObject:treeController withKeyPath:@"selection.canAddNew" options:nil];

I get gibberish back not canAddNew when I log the result in testToAdd (and I change the selection in my NSOutlineView). The documentation clearly states that selection returns a proxy object. Does that mean bindings set through interface builder are doing behind the scene magic like:

[[[treeController selectedObjects] objectAtIndex: 0] canAddNew];

Doesn't this mean that my bound method (accessor set) needs to have an understanding of NSObjectController classes and use the above selectedObjects code to get the value?

It seems like I must be missing something when creating bindings programatically.

Is there a better way to get the same behavior as IB through code? Or should I just observe selection or selectedObjects and then use the above code to get the actual object?

--Derrek
_______________________________________________
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


  • Prev by Date: Re: Re: Get selectedItem (and items) in NSOutlineView
  • Next by Date: Stripping newlines/blanks when pasting on an NSTextField
  • Previous by thread: Re: Get selectedItem (and items) in NSOutlineView
  • Next by thread: Stripping newlines/blanks when pasting on an NSTextField
  • Index(es):
    • Date
    • Thread