Why not use your top level NSUserDefaults  as a dictionary and use each monitor 
name as a key for each object in the dictionary?  Is that too clunky?

https://developer.apple.com/documentation/foundation/nsuserdefaults

A default object must be a property list—that is, an instance of (or for 
collections, a combination of instances of) NSData 
<https://developer.apple.com/documentation/foundation/nsdata>, NSString 
<https://developer.apple.com/documentation/foundation/nsstring>, NSNumber 
<https://developer.apple.com/documentation/foundation/nsnumber>, NSDate 
<https://developer.apple.com/documentation/foundation/nsdate>, NSArray 
<https://developer.apple.com/documentation/foundation/nsarray>, or NSDictionary 
<https://developer.apple.com/documentation/foundation/nsdictionary>.

Am I missing something here?

Alex Zavatone

> On Apr 2, 2021, at 4:05 PM, Gabriel Zachmann via Cocoa-dev 
> <cocoa-dev@lists.apple.com> wrote:
> 
> I used to manage different NSUserDefaults in my app depending on which 
> monitor it runs.
> So, I create filenames of the user defaults like this:
>  NSString * defaults_name = [ NSString stringWithFormat:@"de.zach.MyApp.%@", 
> displayname ];
> 
> Then I used to create the NSUserDefaults object with an unusual approach,
> but that does not seem to work any more.
> 
> So, I am wondering, what is the correct and easy approach to managing 
> different user settings (user defaults)?
> 
> Note that my app is sandboxed, so the user defaults must go in 
>  ~/Library/Containers/de.zach.MyApp/Data/Library/Preferences/
> , must they not?
> 
> I looked at -initWithSuiteName , but it seems to me that is not they proper 
> approach, is it?
> 
> Thanks a lot in advance for all kinds of insights and help!
> 
> Best regards, Gabriel
> 
> 
> 
> _______________________________________________
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> 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/zav%40mac.com
> 
> This email sent to z...@mac.com

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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 arch...@mail-archive.com

Reply via email to