Can't load preferences value with CFPreferencesMBS

A couple of weeks ago I posted in https://forum.xojo.com/43872-inspecting-variant-data/ that I had problems with with loading variant data. Turns out I was wrong and the preference value itself is the problem.

This code here fails:

EmailClientDictionary = globals.thePrefs.GetPrefDictionary("EmailInfo_MailApps")

where GetPrefDictionary starts with

dim theCFPrefs as new CFPreferencesMBS Dim theCFObject As CFObjectMBS = theCFPrefs.CopyAppValue(NewCFStringMBS(fieldName), theCFPrefs.kCFPreferencesCurrentApplication) if theCFObject = Nil then Return nil

I had sent the users a version for testing which shows that the “return nil” is done here. Then I had the customers send me a preference file, which shows that “EmailInfo_MailApps” is available and has the correct data. I also had the customers do an AppleScript with

do shell script "defaults read com.mothsoftware.mailarchiverx"

getting

[quote] “EmailInfo_MailApps” = {
Entourage = “{\\\\“ServerName\\\\”:\\\\”\\ …[/quote]

as result.

Am I going mad? The code works for most customers. Does anyone have an idea why ages old MBS code wouldn’t work for some customers? Still a High Sierra only problem.

Apple messed it up maybe?

Gods, I hope not. The usual question is: is it just me or is it everyone. Since I haven’t heard anything about this it must be just me screwing up something.

I seem to remember a problem with mixing either the hosts or the users. I ended up with a shadow copy of the prefs. But I fixed this.

Could the pref reverting code make a problem? I save a copy of the values when opening a window:

Public Function getAllPrefs() as CFDictionaryMBS dim theCFPrefs As new CFPreferencesMBS dim theDictionary as CFDictionaryMBS = theCFPrefs.CopyDictionary(theCFPrefs.kCFPreferencesCurrentApplication, theCFPrefs.kCFPreferencesCurrentUser, theCFPrefs.kCFPreferencesAnyHost) Return theDictionary End Function

and can revert to the saved values with

Public Sub RevertToSaved(oldValues as CFDictionaryMBS) if oldValues = Nil then Return dim theCFPrefs As new CFPreferencesMBS theCFPrefs.SetMultiple(oldValues, Nil, theCFPrefs.kCFPreferencesCurrentApplication, theCFPrefs.kCFPreferencesCurrentUser, theCFPrefs.kCFPreferencesAnyHost) if not theCFPrefs.AppSynchronize(theCFPrefs.kCFPreferencesCurrentApplication) Then Break End Sub