Hey I keep getting this BAD Access at the line
try managedContext.save()
The Code Runs pefectly until it try to Save my value. I think it might be becuase im using a "copy" of the Entity and not the actual Entity. But this is nessecary as you cant actaully edit the orignal model in code. So all i have to do is stop this Bad access when trying to ".save()" and im good. it is at the 4th last line of code.
So basically when using try managedContext.save(). I create a catch that will print error. so i put the "!" symbol in from of "try" so that i can see why the application throws the error and this is what i got
fatal error: 'try!' expression unexpectedly raised an error: Error Domain=NSCocoaErrorDomain Code=134020 "The model configuration used to open the store is incompatible with the one that was used to create the store."
Code:
let appDelegate = (UIApplication.sharedApplication().delegate as! AppDelegate)
let managedContext: NSManagedObjectContext = appDelegate.managedObjectContext
var properties0 = Array<NSAttributeDescription>()
let playersList0 = NSEntityDescription.entityForName("PlayersList1", inManagedObjectContext: managedContext)
let copy = playersList0!.copy() as! NSEntityDescription
let contentTypeAttribute0 = NSAttributeDescription()
contentTypeAttribute0.name = "firstName"
contentTypeAttribute0.attributeValueClassName = "firstName"
contentTypeAttribute0.attributeType = .StringAttributeType
contentTypeAttribute0.optional = true
properties0.append(contentTypeAttribute0)
copy.properties = properties0
let playerslistCopyto = NSManagedObject(entity: copy, insertIntoManagedObjectContext: managedContext)
playerslistCopyto.setValue("John", forKey: "firstName")
do {
try managedContext.save()
} catch {
print("Error") //prints Error everytime
}
This prints "Error" Everytime as the catch. I basically just need to find out how to save the "copy"