• 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: Can initialKey & initialValue be set via bindings?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can initialKey & initialValue be set via bindings?


  • Subject: Re: Can initialKey & initialValue be set via bindings?
  • From: Quincey Morris <email@hidden>
  • Date: Thu, 16 Jun 2016 02:10:51 -0700
  • Feedback-id: 167118m:167118agrif8a:167118sRX_UYbWvB:SMTPCORP

On Jun 15, 2016, at 21:23 , John Chacho <email@hidden> wrote:
>
> If not, how can I add an arbitrary new record into the dictionary?

If I understand correctly, you have to go the long way round for this scenario (which is not specific to NSDictionaryController). Instead of connecting your Add button to the standard “add:” action of the NS…Controller, you must instead create a custom action method, e.g. ‘addEntry:’. In this method, you’ll need to get hold of the current selection (if that’s where the "based on” values come from), verify that it’s suitable for creating a new entry, create the entry, then add the new entry to your data model dictionary KVO compliantly — or use the NS…Controller’s ‘addObject:’ method, which causes a KVO compliant update. (Both ways are equally easy for an underlying NSDictionary, since it provides KVO compliance for free, but it can be slightly harder for other underlying collection types.)

In effect, the above is exactly what the ‘add:’ action method does, except that it can’t customize the data model object it creates to add.

_______________________________________________

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


  • Follow-Ups:
    • Re: Can initialKey & initialValue be set via bindings?
      • From: John Chacho <email@hidden>
References: 
 >Can initialKey & initialValue be set via bindings? (From: John Chacho <email@hidden>)

  • Prev by Date: Can initialKey & initialValue be set via bindings?
  • Next by Date: Re: Selected value binding in popups
  • Previous by thread: Can initialKey & initialValue be set via bindings?
  • Next by thread: Re: Can initialKey & initialValue be set via bindings?
  • Index(es):
    • Date
    • Thread