NSUserDefaults String Array

I have a string array that I want to save in NSUserDefaults but struggling with the syntax a bit.

If the array is MyArrayValues how do I load/save this?
Load?
Dim defaults As Foundation.NSUserDefaults = Foundation.NSUserDefaults.StandardUserDefaults
MyArrayValues() = defaults.StringArrayForKey(MyArrayValues as CFStringRef)

Save?
Dim defaults As Foundation.NSUserDefaults = Foundation.NSUserDefaults.StandardUserDefaults
defaults.StringArrayForKey(MyArrayValues as CFStringRef)

You will need ParseJSON when reading and GenerateJSON when saving

Not 100% sure but I think you use SetObjectForKey and pass the NSArray as the object. Then you can retrieve with ObjectForKey.

Ok will try :slight_smile:

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.