In the AppStore version of my app the SSBs aren’t working anymore. Saving is okay. But when the app is Sandboxed then the result of getting the folderitem back always is Nil. I had a look with Christian at the code, but he also didn’t have an idea.
[code]Private Function getPrefFolderitemLite(fieldName as string) as Folderitem
'get data from preferences
if fieldName = “” then Return Nil
if not CheckForPrefs then Return Nil
if not theCFPrefs.AppSynchronize(theCFPrefs.kCFPreferencesCurrentApplication) Then
globals.theErrorLog.DialogErrorProceed(kErrorSynchronize)
end if
Dim theCFObject As CFObjectMBS = theCFPrefs.CopyAppValue(NewCFStringMBS(fieldName), theCFPrefs.kCFPreferencesCurrentApplication)
if theCFObject = Nil then Return nil
'get base64 encoded path
dim theData as String = DecodeBase64(CFStringMBS(theCFObject).str)
if theData = “” then Return Nil
dim theFolderitem as new FolderItem(theData, FolderItem.PathModes.Native)
Return theFolderitem
End Function
[/code]
[code]Private Sub setPrefFolderitemLite(fieldName as string, fieldValue as Folderitem)
'set a folderitem preference value
if fieldName = “” then Return
'just encode the path in base64
dim theData as String
if fieldValue <> Nil then theData = EncodeBase64(fieldValue.NativePath)
'make CFObjectMBS
dim theCFObject As CFObjectMBS = NewCFStringMBS(theData)
'save to prefs
if not CheckForPrefs then Return
theCFPrefs.SetAppValue(NewCFStringMBS(FieldName), theCFObject, theCFPrefs.kCFPreferencesCurrentApplication)
if not theCFPrefs.AppSynchronize(theCFPrefs.kCFPreferencesCurrentApplication) Then
globals.theErrorLog.DialogErrorProceed(kErrorSynchronize)
end if
End Sub
[/code]
Does anyone have an idea what might cause the problem? I’m really out of ideas. For now I have made a workaround with a global because the folderitem doesn’t absolutely need to be saved. But it’s really not a good idea with the global.
Xojo 2019r3, MBS latest version. Different versions of macOS.