classPreferences on GitHub

Added picture datatype to classPreferences

You can now store and retrieve pictures in your preferences database

[quote=114745:@Norman Palardy]Does it happen to use NSPreferences/CFPreferences on OS X ?
If not you won’t be able to use it in an App submitted to the App store [/quote]

Norman, have we concluded that this statement was not correct? This class is simply writing a SQLite database to SpecialFolder.ApplicationData which I understand sandboxed apps have access to, also not using NSPreferences/CFPreferences should be no problem as I am simply creating a database which could be for any use.

Yes, that is correct. You don’t need NSPreference for your work.

Here is an example how Microsoft supports the storing of preferences in XML files. In practise it is used by a lot of developers in this form or self written classes. This is only one of many example sites:
http://www.dondraper.com/2011/01/easily-save-and-retrieve-application-and-user-settings-in-vb-net-or-c-apps/

Its inaccurate
IF you try to write “preferences” to the system specified & recommended locations, which I’d suggest you do, using anything BUT NSPreferences\CFPreferences your app will be rejected
However, you can write avoid or ignore the guidelines & write to the Application Data

[quote=115053:@Torsten Gaidies]
Here is an example how Microsoft supports the storing of preferences in XML files. In practise it is used by a lot of developers in this form or self written classes. [/quote]
You can do whatever you want - I just said its not whats recommended
And it can / may have issues in certain environments

For both OS X & Windows a single user on a single machine its unlikely to be an issue
In a more “corporate” set up its more likely to have issues if registries are floating and application data isn’t

Just saying that MS and Apple recommend these things for a reason - you ignore those recommendations at your own peril

Have a nice day

it returns whatever datatype the accepting variable is…

So you could say…

inifile.put(“section”,“key”,3.2) ’ INTERNALLY everything is stored as a string

and

dim s as string
s=inifile.get(“section”,“key”,default)
and get a string back

or
dim s as double
s=inifile.get(“section”,“key”,default)
and get a double

part of the beauty of overloads :slight_smile:

CrossPlatform INI Style Preferences

Like anything in the world of coding, the way we choose to go, depends on the things/problems that have to be done/solved in the given time and other constraints.

I can understand that you want to support the ways you described, in special with the focus on a more “corporate” environment. If Xojo introduces the functionality of storing preferences in an easy way, it would be absolutely welcome.

I wish all of you a nice, shiny weekend in peace.

[quote=115082:@Torsten Gaidies]Like anything in the world of coding, the way we choose to go, depends on the things/problems that have to be done/solved in the given time and other constraints.

I can understand that you want to support the ways you described, in special with the focus on a more “corporate” environment. If Xojo introduces the functionality of storing preferences in an easy way, it would be absolutely welcome.
[/quote]

It has more to do with behaving the way users expect given what ever environment they’re using
For instance if you don’t use CFPreferences then there are third party tools that won’t work that reasonably should that can / should let you alter “Preferences” in your app without using your app
People expect that to work

And CFPreferences / NSPReferences actually have a way to synchronize them so the on disk vs in memory versions match up
And there are again third party tools that people use to alter things while your app is running and then force a resync

That won’t work if you don’t use the recommended mechanisms

[quote=115018:@Norman Palardy]Those are more like PLIST files for app bundles on OS X

http://msdn.microsoft.com/en-ca/library/1xtk877y(v=vs.90).aspx[/quote]

I got my configs mixed up. I’ve been using app.config to store default configurations and my.settings.save to save any user specific changes to user.config in the user’s appdata directory.

http://msdn.microsoft.com/en-us/library/saa62613.aspx

Works great for the programs I have to write in my day job.

Ah yes
Except see Limitations of Application Settings http://msdn.microsoft.com/en-us/library/k4s6c3a0.aspx
Which makes it not quite suitable for our use

[quote=115084:@Norman Palardy]It has more to do with behaving the way users expect given what ever environment they’re using
For instance if you don’t use CFPreferences then there are third party tools that won’t work that reasonably should that can / should let you alter “Preferences” in your app without using your app
People expect that to work

And CFPreferences / NSPReferences actually have a way to synchronize them so the on disk vs in memory versions match up
And there are again third party tools that people use to alter things while your app is running and then force a resync

That won’t work if you don’t use the recommended mechanisms[/quote]
Well It sounds like these mechanisms really should be part of xojo then.

Hence why I said way back

[quote=114928:@Norman Palardy]I really need to factor out our Preferences handling from the IDE so you can just use it in your app and not worry about this
It uses CFPreferences on OS X, the registry on Windows & a hidden named file in your home dir on Linux (which is pretty standard)[/quote]
How it does what it does is pretty straight forward.
Its one module.
Theres one public “Preferences” class you interact with. It’s a Proxy.
It has all the methods for reading & writing booleans, colors, integers, strings etc including dictionaries of things.
Also in the module are are 3 different classes - “preferences providers” - each implements an interface and the Preferences class creates one based on what platform you’re on.
You read & write from the Preferences class and the rest is handled invisibly for you.

It might actually work better as an example in the design patterns examples since that way every has the source if they want to tweak it but you can still just add it to your projects & be done with preferences.

Sounds like a plan… Next release feasible?

I can make no promises.

I was hoping you would say, yes it will be next release with iOS and 64bit :wink:

[quote=114958:@Torsten Gaidies]It may be the correct way, because Microsoft suggest it. But it isn’t the right way. Microsoft could do better, to keep their system KISS.

Personaly I’ won’t store any data in the registry. So I hope, that there is an additional preference storing possibility, like saving to a given FolderItem.

My customers should be able, to easyly copy and paste their data and settings from one system to another.[/quote]
What is wrong with using XML documents?

You really should know we don’t make promises of things in the future :slight_smile:

Reread the rest of this thread rather than making us repeat it

Sorry.

I know. I don’t blame you. I’ve seen the grief people dish on here about it.

and Geoff wont make any. So we can only ask and see.