• 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: NSPopUpButton binding value/selected problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSPopUpButton binding value/selected problem


  • Subject: Re: NSPopUpButton binding value/selected problem
  • From: Jerry Krinock <email@hidden>
  • Date: Fri, 18 Oct 2013 19:11:26 -0700

On 2013 Oct 17, at 11:35, Trygve Inda <email@hidden> wrote:

> I bind the popup:
>
> Content (myArray.arrangedObjects)
> Content Objects (myArray.arrangedObjects.Identifier)
> Content Values (myArray.arrangedObjects.Name)

I didn't have time today to really understand what you are doing.  I'll just say that using Cocoa Bindings on popups, or any menu for that matter, is not a good idea.

The advantage of Cocoa Bindings is that it keeps model and view in sync without your code having to watch them.  You must trade this off against the disadvantages of Cocoa Bindings, which I'm not going to list here.  One of them may be causing the issue you're having.

But in fact you don't have to watch a menu, because a menu is invisible and dormant until a user clicks it, and when that happens you can do whatever updating is needed in the delegate method -menuNeedsUpdate:, and everything remains frozen until the user invokes one action (or does not) and  then a target gets an action message.  You don't have to worry about things happening behind the scenes.  It's all very simple and straightforward.

So, when you use Cocoa Bindings on a menu, you get no advantage, but all of the disadvantages.  Think about using -menuNeedsUpdate:, target, and action instead.


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


References: 
 >NSPopUpButton binding value/selected problem (From: Trygve Inda <email@hidden>)

  • Prev by Date: Re: modal window and quit menu item
  • Next by Date: Re: NSDocument and KVO compliance
  • Previous by thread: Re: NSPopUpButton binding value/selected problem
  • Next by thread: Re: NSPopUpButton binding value/selected problem
  • Index(es):
    • Date
    • Thread