NSUserDefaultsMBS

Where would I find this on the system?
What is the path when it is written?

dim u as NSUserDefaultsMBS = NSUserDefaultsMBS.standardUserDefaults
u.setStringValue “com.rushsoftware.CrosswordWizardPlayer.CWPIAP001”, “TRUE”

Why do you want to do this? The correct way to access settings is through NSUserDefaults. Loading the property list directly is hacky and you’ll have trouble writing the file back out.

SpecialFolder.Preferences.Child(“your.bundle.identifier.plist”), but again you will have extreme difficulty writing there.

Just like Apple told everyone not to parse the version string but Xojo did anyway and that ■■■■■■ everyone over, Apple tells us to use the APIs for preferences and have made hacking them not easy to do. Take the lead from Xojo’s most recent screw up. Do it how Apple says to.

Hi Tim,

I have probably made a mess of it but this is how I was reading and writing if a user made an IAP

//If User made the purchase set to true
dim u as NSUserDefaultsMBS = NSUserDefaultsMBS.standardUserDefaults
u.setStringValue “com.rushsoftware.CrosswordWizardPlayer.CWPIAP001”, “TRUE”

//When App opens check if payment was made
Const purchaseID = “com.rushsoftware.CrosswordWizardPlayer.CWPIAP001”
App.IsPurchaseMade = NSUserDefaultsMBS.standardUserDefaults.BoolForKey(purchaseID)

Is this not correct?

As far as reading and writing preferences, that looks correct. You may need to call synchronize after writing, I can’t recall the specifics of when that gets automated.

Do you have a particular issue that raised the question “where are the files?”

The preferences file for sandboxed apps is at the usual location deep into Library/Containers. If you can edit a file but don’t know the location you can use Find Any File to find files that were changed in the last x minutes. Additionally, there are apps like PrefsEditor to open and edit preferences files.

1 Like

I just wanted to know in case I needed to delete it after fooling around testing a bunch of thing (not knowing what I was really doing :slight_smile: ) Thanks for the followup.

To delete it, use the Terminal command “defaults delete your.bundle.identifier”.
Or use my (made with Xojo) app “Prefs Editor.app” and then open the prefs, Select All, and delete them with the Backspace key.

3 Likes

Thanks Thomas