COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :
Old 03-27-2018, 05:15 AM   #1
SaschArt
Human being with feelings
 
SaschArt's Avatar
 
Join Date: Aug 2013
Posts: 236
Default Store settings

What solution is there to store settings for the plugin in cross platform.

In windows there is a registry but in OSX ?
__________________
Audio plugins | BrainWaveProducer | EmRysRa
SaschArt is offline   Reply With Quote
Old 03-27-2018, 10:17 AM   #2
Bobflip
Human being with feelings
 
Join Date: Nov 2016
Posts: 341
Default

Are you on WDL-OL or WDL-Youlean?
Bobflip is offline   Reply With Quote
Old 03-27-2018, 10:20 AM   #3
olilarkin
Human being with feelings
 
Join Date: Apr 2009
Location: Berlin, Germany
Posts: 1,248
Default

i use the win32 api/swell

you can look at the app wrapper to see how it's done

https://github.com/olilarkin/wdl-ol/...p_main.cpp#L41
__________________
VirtualCZ | Endless Series | iPlug2 | Linkedin | Facebook
olilarkin is offline   Reply With Quote
Old 03-28-2018, 02:22 AM   #4
SaschArt
Human being with feelings
 
SaschArt's Avatar
 
Join Date: Aug 2013
Posts: 236
Default

Cannot find the solution there Oli.

I tried to write a file with the settings in /Library/Preferences but starting from a while, the plugin can no longer write files in this folder

From what I found NSUserDefaults can be alternative to registry entry but I have not found any code examples so far.
__________________
Audio plugins | BrainWaveProducer | EmRysRa
SaschArt is offline   Reply With Quote
Old 03-30-2018, 11:49 AM   #5
SaschArt
Human being with feelings
 
SaschArt's Avatar
 
Join Date: Aug 2013
Posts: 236
Default

I tried to use NSUserDefaults but this code crash the DAW:

Code:
NSString *savedValue = [[NSUserDefaults standardUserDefaults] stringForKey:@"preferenceName"];
Do not understand why
__________________
Audio plugins | BrainWaveProducer | EmRysRa
SaschArt is offline   Reply With Quote
Old 04-02-2018, 06:29 AM   #6
SaschArt
Human being with feelings
 
SaschArt's Avatar
 
Join Date: Aug 2013
Posts: 236
Default

Solution:

Code:
	bool insertPref(const char *prefname, const char *prefvalue) {	
		NSString* nsprefname;
		NSString* nsprefvalue;
    
		nsprefname = [NSString stringWithUTF8String:prefname];
		nsprefvalue = [NSString stringWithUTF8String:prefvalue];

		NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];	  
		if (prefs) {
			[prefs setObject:nsprefvalue forKey:nsprefname];
			return true;
		}
		return false;
	}
	char *getPref(const char *prefname) { 
		NSString* nsprefname;

		nsprefname = [NSString stringWithUTF8String:prefname];

		NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
		if (prefs) {
			NSString *nsvalue = [prefs stringForKey:nsprefname];
			if (nsvalue.length>0) {
				return (char *)[nsvalue UTF8String];
			}
		}
		char *out= "";
		return out;
	  
	}
__________________
Audio plugins | BrainWaveProducer | EmRysRa
SaschArt is offline   Reply With Quote
Old 03-09-2021, 03:12 AM   #7
SaschArt
Human being with feelings
 
SaschArt's Avatar
 
Join Date: Aug 2013
Posts: 236
Default

It seems that iOS 10 does not save the settings on the given code earlier.

Quote:
Originally Posted by olilarkin View Post
i use the win32 api/swell

you can look at the app wrapper to see how it's done

https://github.com/olilarkin/wdl-ol/...p_main.cpp#L41
The solution to save the settings in a file raises the issue of permissions. I do not know if in all situations of plugin files saving it's a good idea. What should I make sure no problems arise here?
__________________
Audio plugins | BrainWaveProducer | EmRysRa
SaschArt is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 03:21 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.