Skip navigation.
 
mlsetting layered user defaults?
FROM : Mark Dawson
DATE : Sat Apr 30 06:33:46 2005

I wasn't sure of how to set a user default that is part of layers of 
dictionaries:

What I'm not sure how to do is set the "UnitsKey" (which isn't unique) 
and is inside the Tool_XXX_DefaultKey (is unique) dict which is inside 
the Tool_DefaultKey dict (is unique).  What I'm not clear about is 
whether the below code is getting a local copy of a dictionary, or 
whether the NSUserDefaults database is being updated by my final set. 
Am I doing this correctly, or is there a more correct way of doing 
things?  Thanks!


Do I do the following:
    NSUserDefaults *usrD=[NSUserDefaults standardUserDefaults];

    ][[usrD objectForKey: ToolDefaults]  // <<- returns an NSDictionary 
object
            objectForKey: Tool_XXX_DefaultKey]  // <<--returns another 
NSDictionary object
                  setObject:  [NSNumber numberWithInt:defaultUnits] 
forKey: UnitsKey]]  // <<-- now set that object


If I register the following :
   NSDictionary *dict= [NSDictionary dictionaryWithObjectsAndKeys:
           createToolsDictionaryFromDoc(&ToolDefaults),                    Tool_DefaultKey,    
             ...,
           nil];

Where         
createToolsDictionaryFromDoc
  does a a return NSDictionary dictionaryWithObjectsAndKeys:
           createTools_XXX_DictionaryFromDoc(&ToolDefaults),                    
Tool_XXX_DefaultKey,    
             ...,
           nil];

and
    createTools_XXX_DictionaryFromDoc
        does a  return [NSDictionary dictionaryWithObjectsAndKeys:
           [NSNumber numberWithInt:defaultUnits],    UnitsKey,
           ....
           nil];

Related mailsAuthorDate
No related mails found.