0

I am trying to make an app that has to store some values, but i don't know how to do it.

struct mat {
    var a: String
    var b: [Int]
    var c: Double
}        

var subj = [mat]()

I had a look at CoreData but i didn't understand it, can it store arrays?

this is what i would like to save and have access to after the app is reloaded.

How can i save the array of structures? or each individual structure? or can i do it some other way?

P.S. I don't have a lot of experience in coding with swift

Sulthan
  • 128,090
  • 22
  • 218
  • 270
AlexS
  • 1
  • 1

1 Answers1

1

If you just doing a simple app for practice/tutorial purposes, you should be fine with storing your data to UserDefaults.

// to store
let userDefaults = NSUserDefaults.standardUserDefaults()
userDefaults.setObject(yourArray, forKey:"yourArray")
userDefaults.synchronize()

// to retrieve
var yourArray = userDefaults.objectForKey("yourArray")
Eugene Gordin
  • 4,047
  • 3
  • 47
  • 80