• 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: Simple bindings problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Simple bindings problem


  • Subject: Re: Simple bindings problem
  • From: Martin Linklater <email@hidden>
  • Date: Sun, 6 Jan 2008 08:22:19 +0000


On 6 Jan 2008, at 00:24, mmalc crawford wrote:

Well, how do you do it currently?

Currently in my test app I have an NSPopUpMenu, an NSTextField next to it, and two NSButtons (Add and Remove). My NSPopUpMenu is bound to my array controller, which has it's contents initialised in my AppControllers init method. This inits the NSPopUPMenu with 4 strings. I have the Add and Remove buttons triggering the insert: and remove: actions of the array controller.



How do you want to do it?

What I would like is for whatever string I enter into the NSTextField to be used as the string for the new NSPopUpMenu entry.



What opportunities do the controller classes give for customising the process?

This is the bit I'm investigating. I had hoped there would be a way for the NSArrayController's 'insert' action to take a parameter setting the contents of the newly created object - kind of a 'use this object to initialise the new object' setting in the bindings pane. But it seems like this is not possible using IB alone - all you can do is insert a new, empty object into the array.


After googling for a bit last night I found this on CocoaDev:

There are a number of ways to customize new objects that get added to the array:

Subclass NSArrayController and override newObject or addObject.
Register as an observer of the array's key in the providing object, using KeyValueObserving. You will be informed when a new object is added to that array, which you can then modify (the new object will be passed to you.)
In the object providing the content array, implement the KeyValueCoding array methods, one of which is insertObject:in<Key>AtIndex?:.


So I'm looking at implementing these suggestions... I just thought there may be a way to do it without writing any code... just by setting things up in IB.

Thanks.



mmalc


_______________________________________________

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: Simple bindings problem
      • From: mmalc crawford <email@hidden>
References: 
 >Simple bindings problem (From: Martin Linklater <email@hidden>)
 >Re: Simple bindings problem (From: Martin Linklater <email@hidden>)
 >Re: Simple bindings problem (From: Martin Linklater <email@hidden>)
 >Re: Simple bindings problem (From: mmalc crawford <email@hidden>)

  • Prev by Date: Re: thread protocol modifiers
  • Next by Date: Re: thread protocol modifiers
  • Previous by thread: Re: Simple bindings problem
  • Next by thread: Re: Simple bindings problem
  • Index(es):
    • Date
    • Thread