I have an array of data that I have created in Swift in Xcode.
I have setup a structure to store my data using the following code:
struct groups {
var groupName: String!
var groupPeripherals: [CBPeripheral]!
}
The arrays work fine and the array is held until the app is closed.
I have then created an array using this structure as so:
var groupArray = [groups]()
Throughout the app, I have appended data to this array like this, for example:
groupArray.append(groups(groupName: "Group 1", groupPeripherals: [peripheral info...]))
Where I have written 'peripheral info', it actually passes the CBPeripheral information to the array.
Anyway, to the question. I want to be able to store this array in NSUserDefaults and be able to read it when I restart the app. How would I go about doing this? I know how to use NSUserDefaults with Strings and Integers etc, but not this kind of array. Any help would be appreciated here.
Thanks!