there is a way. You can execute each item manually, for example. You have an array:
let employee: NSMutableArray = [] employee.addObject(["name":"Bill","LastName":"Hanks"]) employee.addObject(["name":"Rolex","LastName":"Swarzer"]) employee.addObject(["name":"Clive","LastName":"Martin"]) employee.addObject(["name":"Jimi","LastName":"Hendrix"])
Assuming you created your coreData with Entity "Employee" and the attributes "name" and "lastname", you do the following to add it to ...
let appDel = UIApplication.sharedApplication().delegate as! AppDelegate let context = appDel.managedObjectContext for item in employee { do { let newUser = NSEntityDescription.insertNewObjectForEntityForName("Employee", inManagedObjectContext: context) newUser.setValue(item["name"], forKey: "name") newUser.setValue(item["LastName"], forKey: "lastname") try context.save() } catch {
You can then retrieve all the elements using a select query or an NSFetched Results controller
source share