discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to add a defaults database to a theme ?


From: Richard Frith-Macdonald
Subject: Re: How to add a defaults database to a theme ?
Date: Fri, 10 May 2019 12:35:28 +0100


> On 10 May 2019, at 12:24, Bertrand Dekoninck <bertrand.dekoninck@gmail.com> 
> wrote:
> 
> On 2019-05-10 13:06:02 +0200 Fred Kiefer <fredkiefer@gmx.de> wrote:
> 
>> Hi Bertrand,
>> 
>> I think you are misreading the compiler warning. This just complains that 
>> the 
>> class that this method is on already has an instance variable with the name 
>> „defaults“. You should just use a different name for your local variable 
>> instead. Maybe something like „user_defaults“?
>> 
>> Hope this helps,
>> Fred
> Thanks,
> 
> I can get rid of the warning in this way, but I think my problem is 
> different. 
> In the code hereafter, is standardUserDefaults the database of the theme, or 
> the database of the app using the theme ? If it's the theme 's one, how could 
> I write to it with the command line. Should I use the bundle identifier ?

NSUserDefaults has multiple databases (called 'domains') in a list which 
defines their order of precedence, so when you ask for a default, and multiple 
domains in the list contain the default name, you get the correct value 
returned (the one from the first domain that contains a value for the key).

The normal order of the important domains here is

Command line arguments,  Application, NSGlobalDomain, GSThemeDomain, 
Registration (hard coded and set on application startup)

GSThemeDomain is set up by your theme (information in a property list in the 
theme bundle) and changes whenever a new theme is made active in an app, so to 
get the behavior you want, you need zero coding, you just have to put the 
key/value pair into your GSThemeDomain and it will be used unless the user 
overrides it by setting a value in a higher precedence domain (eg on the cmmand 
line).


reply via email to

[Prev in Thread] Current Thread [Next in Thread]