Real Software Forums
http://forums.realsoftware.com/

New Preference Solution!
http://forums.realsoftware.com/viewtopic.php?f=1&t=39574
Page 2 of 2

Author:  Jason_Adams [ Tue Nov 22, 2011 9:21 pm ]
Post subject:  Re: New Preference Solution!

Hey Tristan,

I get a compiler error. The LastErrorCode computed property has an empty set method, so the line LastErrorCode = 0 in XDB.Save causes an error.

Thanks for the excellent storage classes! :)

Author:  tbg10101 [ Wed Nov 23, 2011 12:31 am ]
Post subject:  Re: New Preference Solution!

Fixed the issues by setting mLastErrorCode instead. Download link has been updated: http://cl.ly/C3Fd

Author:  Jason_Adams [ Fri Feb 10, 2012 2:36 pm ]
Post subject:  Re: New Preference Solution!

I'm considering switching over to the XDB class, but I'm curious how it handles objects. I have data type only classes that I store into my current Plist class, but I've had to set these up manually. If XDB has has a more elegant way of storing objects, I'd be glad to switch over to it.

Thanks for the excellent work!

Author:  tbg10101 [ Fri Feb 10, 2012 3:42 pm ]
Post subject:  Re: New Preference Solution!

XDB does not store objects because I don't know of any way of serializing objects.

Author:  Jason_Adams [ Fri Feb 10, 2012 3:51 pm ]
Post subject:  Re: New Preference Solution!

If you're able to store dictionaries, I would do it in a similar fashion:

Use introspection to retrieve the object properties. First, make sure every property is data type only, as I'd only support objects one level deep. Then, move from property to property storing them key-value form like you would a dictionary, using the name as the key. Not too bad.

The only thing I'm not sure of is if you can use introspection to create an object by a string name... I don't believe so. If you could you'd simply store the type name along with the other values and use it to reconstruct the object. This isn't a catch all for all objects, but it would certainly handle single-level objects.

A thought. I honestly don't know if it would work on the retrieval end.. I doubt it. :)

The class I'm using, PLIST, has a sort of means for constructing and deconstructing objects into and from dictionaries. I use a key to store the entire key-value array, then use the key to tell myself what it was. It's a bit of extra work, but it does the job well.

Thanks, Tristan!

Author:  tbg10101 [ Fri Feb 10, 2012 6:07 pm ]
Post subject:  Re: New Preference Solution!

Is there an example of introspection that I could look at? I have no idea how to reconstruct either.

Also, XDB sores n-depth arrays and dictionaries so I'd have no problem writing a recursive function for object property types. :D

Author:  eduo [ Thu May 03, 2012 4:56 pm ]
Post subject:  Re: New Preference Solution!

Hi.

I was looking around and "rediscovered" Xprefs. At the time I dismissed it because it didn't use CFPreferences. This was brought up by other users as a potential problem when submitting to the MAS.

Was it ever updated to handle native methods in each platform? That's CFPreferences for Mac and, I guess, writing to the registry in Windows Pre-7 (and to an xml in Windows 7).

Author:  tbg10101 [ Thu May 03, 2012 6:39 pm ]
Post subject:  Re: New Preference Solution!

No but it now writes to the Application Support (you must supply a sub-folder name) folder which is supported by the MAS and is the way many windows apps store settings.

Page 2 of 2 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/