I tested the fast iPhone project using Xcode 6 beta 2. The project uses basic data to access two objects (User / Contract) in the data model. Inside the iOS simulator everything works fine.
Problem. When I create an application for IOS7 and test the application on my iPhone5 (with the launch of IOS 7.1.1), the program can only save data in the first object (as defined in the basic data model = User). For all other objects, NSEntityDescription.entityForName (...) is "nil". In managedObjectModel (println (managedObjectModel)) all objects are included. It seems that the data model is incorrectly included in the SQL database on IOS7 ?! Does anyone have a solution / idea? Thank: -)
var myAppDel:AppDelegate = UIApplication.sharedApplication().delegate as AppDelegate
var myContext:NSManagedObjectContext = myAppDel.managedObjectContext
println(NSEntityDescription.entityForName("User", inManagedObjectContext: myContext))
println(NSEntityDescription.entityForName("Contract", inManagedObjectContext: myContext))
var newContract:AnyObject = NSEntityDescription.insertNewObjectForEntityForName("Contract", inManagedObjectContext: myContext)
newContract.setValue("" + txtContract.text, forKey: "contractName")
myContext.save(nil)
var newUser = NSEntityDescription.insertNewObjectForEntityForName("User", inManagedObjectContext: myContext)
newUser.setValue("" + txtUsername.text, forKey: "userName")
newUser.setValue("" + txtPassword.text, forKey: "userPass")
newUser.setValue(newContract, forKey: "contracts")
myContext.save(nil)
:
- "NSInternalInconsistencyException", : "+ entityForName: " " . '