Answers for "store multiple items in one core data record"

0

store multiple items in one core data record

func insertItems(coreDataTable : String, records: NSArray) -> Bool {
        let error: NSError?
        for(item in records as NSDictionary!) {
            let entity = NSEntityDescription.entityForName(coreDataTable, inManagedObjectContext: self.managedContext)
            var record = NSManagedObject(entity: entity!, insertIntoManagedObjectContext: managedContext) as Record!
            record.name = item["name"]
            if (!self.mainObjectContext.save()) {
                // Replace this implementation with code to handle the error appropriately.
                // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
                NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
                //abort();
                return false
            }
        }
    return true
}
Posted by: Guest on May-03-2021

Code answers related to "store multiple items in one core data record"

Code answers related to "Swift"

Browse Popular Code Answers by Language