PureBasic Forum
https://www.purebasic.fr/english/

How can I set the default values for "NSUserDefaults"
https://www.purebasic.fr/english/viewtopic.php?f=19&t=73209
Page 1 of 1

Author:  Wolfram [ Wed Jul 17, 2019 11:52 am ]
Post subject:  How can I set the default values for "NSUserDefaults"

How can I detect if the program is running the first time an I have to initialize the default values?

In this example here I can see how to use the "NSUserDefaults standardUserDefaults", but how can I set the standard value if the Preferences file is generated.
https://www.purebasic.fr/english/viewtopic.php?p=404904#p404904

In PB it is simple
Code:
ReadPreferenceString("myParameter", "standardValue")

Author:  wilbert [ Wed Jul 17, 2019 6:49 pm ]
Post subject:  Re: How can I set the default values for "NSUserDefaults"

The NSUserDefaults class has a method called registerDefaults: that allows you to set default values.
Most examples use a plist file where you put the default values, parse that file and use the resulting dictionary for the registerDefaults: method.

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/