I'm using the CoreData for the first time and I have done the work to save the values from this tutorial and ewerything works fine.
i created the .swift file with all the function to save the state for the particular object. the values cold be "on" or "off" with its self on or off functions.
there is how the values are saving:
func objectON()
{
let entityDescription = NSEntityDescription.entityForName("Groops", inManagedObjectContext: managedObjectContext!)
let Groop = Groops(entity: entityDescription!, insertIntoManagedObjectContext: managedObjectContext)
Groop.object = "on"
var error: NSError?
managedObjectContext?.save(&error)
if let err = error {
println(err.localizedFailureReason)
}
}
but i have a trouble with loading the data. the tutorial version is realy uncomfortable to use in my situation.
will be good if i create the single function that will returne the value on or off in the same .swift file with saving functions. and may look like this
func loadValue(object: String) -> String {
var value = "loadedValue"
return value
}
so i just can use the if returnedValue == "on" { code }
can someone help me with tis function?