I should have been more clear, the new entries are simple key-value pairs where the values are simple strings.
Your reply helped me understand some of my confusion, but not before I had tried a few crazy ideas and received embarrassing exceptions like: initValue[6961:329407] [<AppController > addObserver:<NSObjectParameterBinder > forKeyPath:@"<some foolish text from IB Initial Value field>" options:0 context:0x6000000e4500] was sent to an object that is not KVC-compliant for the "<something equally embarrassing>" property. and -[NSTextField copyWithZone:]: unrecognized selector sent to instance After revisiting the KVC and KVO documentation, working on something else and forcing myself to not think about the seemingly trivial problem... What I hope is a safe, simple and non-memory-leaky solution popped into focus: 1. Declare and synthesize two properties to hold a key NSString and a value NSString in the controller. 2. Bind the NSTextFields to the properties and check "Continuously Updates Values" 3. Bind the NSDictionaryControl "Initial Key" and "Initial Value" to the properties. PS: Another factor that may have muddied the water for me was not Command-S'ing to save my hasty, fool-hearty and something angry XIB and other file updates before compiling and running. On Thu, Jun 16, 2016 at 2:40 PM, Quincey Morris < [email protected]> wrote: > On Jun 15, 2016, at 21:23 , John Chacho <[email protected]> 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 protected]) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
