iOSKit and R2

Hi Jason

I’m sure you know but just in case… the current version of iOSKit has some issues with the latest Xojo release (mostly just because of Xojo’s new iOSTableCellData). These can be worked around pretty easily though.

I downloaded iOSKit for NSUserDefaults, Keychain and maybe even iCloud and I can see you’ve done a small mountain of work so I just wanted to say thank you for this, it is much appreciated. Would you be able to help me with one quick question? I want to save arrays of integers and strings to NSUserDefaults. On MBS on the desktop, I first created a Variant from each array and then set that. Any idea how I could save an array with iOSKit?

Thanks again!
Gavin

D’oh! This was mean to be a PM to Jason :frowning: Oh well.

Jean-Paul, thanks but not sure what you mean. I’m trying to save arrays of any kind to NSUserDefaults.

[quote=281689:@Gavin Smith]Hi Jason

I’m sure you know but just in case… the current version of iOSKit has some issues with the latest Xojo release (mostly just because of Xojo’s new iOSTableCellData). These can be worked around pretty easily though.

I downloaded iOSKit for NSUserDefaults, Keychain and maybe even iCloud and I can see you’ve done a small mountain of work so I just wanted to say thank you for this, it is much appreciated. Would you be able to help me with one quick question? I want to save arrays of integers and strings to NSUserDefaults. On MBS on the desktop, I first created a Variant from each array and then set that. Any idea how I could save an array with iOSKit?

Thanks again!
Gavin[/quote]
Hi Gavin,
Yes I’m aware, I’ve had no time to fix everything lately unfortunately (and add a few new items). Have you tried joining the array of strings with some escape character and then splitting them when reading? There is no way to save an array natively (even in Swift/obj-c) so anything you do would have to be custom anyway.

I’m glad you’re enjoying using iOSKit. iCloud is not yet working, I couldn’t get the entitlements to work when I was testing so I stopped working on it. Maybe I’ll be able to get back to it at some point in the future to work on getting it to work.

Jason

[quote=281725:@Jason King]Hi Gavin,
Yes I’m aware, I’ve had no time to fix everything lately unfortunately (and add a few new items). Have you tried joining the array of strings with some escape character and then splitting them when reading? There is no way to save an array natively (even in Swift/obj-c) so anything you do would have to be custom anyway.[/quote]

True, I forgot about that as I’ve been using MBS on the desktop which uses a convenience method to write an array to defaults.

Hu? Maybe I missed a part, but can‘t you save arrays to user defaults as well as use the writetofile method of NSArray? You have to convert your Xojo array to an NS(Mutable)Array first of course. On NSUserdefaults, you write the array with setObject:forKey: and read it with arrayForKey:

Yes those methods exist but it can’t be an arbitrary array. It has to be a property list array or all the objects have to be archivable with (if I remember correctly) NSCoding. Unless I read the docs wrong which is possible since it was a while ago that I read them.

Good hint, Jason, thanks! Yes, most datatypes need to be wrapped in NSValues or -Numbers. Quite some work, but one needs that kind of arrays rather frequently … Hmm, I ran into problems with iOSLib myself and have to rebuild a lot of things. Good point to consider too, thx!