It is currently Sun Sep 22, 2019 1:19 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: How can I set the default values for "NSUserDefaults"
PostPosted: Wed Jul 17, 2019 11:52 am 
Offline
Enthusiast
Enthusiast

Joined: Thu May 30, 2013 4:39 pm
Posts: 452
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")


Top
 Profile  
Reply with quote  
 Post subject: Re: How can I set the default values for "NSUserDefaults"
PostPosted: Wed Jul 17, 2019 6:49 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Aug 08, 2004 5:21 am
Posts: 3443
Location: Netherlands
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.

_________________
macOS 10.14 Mojave, PB 5.62 x64


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye