Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdate NSManagedObjects efficently in CoreData
    primarykey
    data
    text
    <p>I have a large amount of data, saved using the Core Data Framework. There are always a lot of updates that have to be made. The Problem is that this updates take too much time.</p> <p>The reason for this is that for each entry in my database I have to make a query to get the corresponding NSObjectModel and then update its attributes. Because there is a lot of data to browse through, it takes a lot of time. If I only create new objects and insert them in my database, this takes much less time, which of course makes sense.</p> <p>So my question is if there is a more efficient way to do this, because I'm really talking about minutes, not seconds.</p> <p>Like I said, I have to get objects from the database very often. You can see it in the code below. Maybe this helps to understand where my problem is:</p> <pre><code>while (additiveElement != nil) { //Get Product Product *product = [Product productWithID:additivID inManagedObjectContext:self.managedObjectContext]; //Get ProductLanguage ProductLanguage *productLanguage = [ProductLanguage productLanguageWithLanguage:self.currentLanguage andProductID:additivID inManagedObjectContext:self.managedObjectContext]; productLanguage.language = self.languageEntity; product.productID = additivID; productLanguage.name = additivName; productLanguage.text = additivText; productLanguage.product = product; product.productFamily = [ProductFamily familyWithID:additivFamilyID inManagedObjectContext:self.managedObjectContext]; if (productFiles != nil) { File *file = [File fileWithName:fileName inManagedObjectContext:self.managedObjectContext]; file.fileName = fileName; file.fileSize = fileSize; file.fileDateNew = fileDate; file.fileType = fileType; file.language = [Language languageWithAbbreviation:@"en" inManagedObjectContext:self.managedObjectContext]; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload