Re: NSUserDefaults and binding to an NSDictionary
Re: NSUserDefaults and binding to an NSDictionary
- Subject: Re: NSUserDefaults and binding to an NSDictionary
- From: Steven Riggs <email@hidden>
- Date: Sun, 19 Oct 2008 20:19:37 -0400
Hey Todd,
This worked for me...
In interface builder, you will need an Array controller
Mode: Class Class Name:NSMutableDictionary
Content Array bound to Shared User Defaults Controller - controller
key:values - modal key path:yourDefaultsKey
Make sure handles content as a compound value is checked here.
Good luck,
Steven Riggs
http://www.stevenriggs.com
On Oct 19, 2008, at 5:16 PM, Todd Ouzts wrote:
Not sure how to best join a thread since there's no "Reply" link on
Apple Mailing Lists, but...
I've been struggling to do what Daniel wants for a week and can't
figure it out either. My user defaults are not a flat list and I
need to be able to bind to subdictionary values in Interface Builder.
I've tried using NSDictionaryController and NSArrayController but
they just generate runtime errors or populate my NSTextFields with
values like "(".
So can you please elaborate, Matt? The only place I see a "Handles
Content as Compound Value" checkbox in IB is on an
NSObjectController. But Apple's docs don't explain when or how to
use this.
There must be a simpler solution to this common issue. I too
expected a syntax like "DictionaryName.KeyName" to work in IB's
Bindings pane. Anything more than that seems heavy-handed.
Thanks,
Todd
On or about 10/16/06 12:15 PM, thus spake "Daniel Tapie"
<email@hidden>:
> Hi Matt,
>
> Are you implying I cannot use the Shared Defaults Controller in
this
> case?
No. m.
> On 16 oct. 06, at 21:02, Matt Neuburg wrote:
>
>> On Mon, 16 Oct 2006 14:23:24 +0200, Daniel Tapie
>> <email@hidden>
>> said:
>>> Hi there,
>>>
>>> I have a simple question regarding bindings and user defaults
and I
>>> could not find an answer in any of the mailing lists (it is
probably
>>> very obvious).
>>>
>>> My user defaults contain a few booleans, strings and numbers
all of
>>> which work fine when bound to various text fields and checkboxes.
>>>
>>> So, my question is: how do I bind values that are included in an
>>> NSDictionary which itself is one of my user defaults?
>>>
>>> Here is the typical structure of my user defaults:
>>>
>>> --> Key: @"Preference 1", Value (NSString): @"any string"
>>> --> Key: @"Preference 2", Value (NSNumber): 1234
>>> --> Key: @"Sub Preferences", Value (NSDictionary):
>>> --> Key: @"Sub Preference 1", Value (NSString): @"any string"
>>> --> Key: @"Sub Preference 2", Value (NSNumber): 4567
>>>
>>>
>>> So, I tried binding a text field to "Sub Preferences.Sub
Preference
>>> 1" but all it does is create a "Sub Preferences.Sub Preference 1"
>>> string and not a dictionary containing the string.
>>
>> Aside from the question of how you are naming your keys, the big
>> trick here
>> is to pass thru a controller where Handles Content as Compound
>> Value is
>> checked. m.
>>
>> --
>> matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
>> A fool + a tool + an autorelease pool = cool!
>> AppleScript: the Definitive Guide - Second Edition!
>> <http://www.amazon.com/gp/product/0596102119>
>>
>>
>>
>>
>
>
>
> Daniel Tapie
>
_______________________________________________
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
_______________________________________________
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