Note that there are some explanatory texts on larger screens.

plurals
  1. PONSManagedObjectContext Reset appears to be losing data?
    primarykey
    data
    text
    <p>My core data store contains 51 <code>Entry</code> entities which have a <code>message</code> attribute reading "Test". Doing an NSFetchRequest for this confirms that they're all there.</p> <p>I have another part of my method however, which will be used for memory intensive purposes, dealing with large chunks of NSData, and so I need to call <code>[oldContext reset];</code> quite often.</p> <p>I have a memory intensive method which accesses a lot of NSData from my MOC. As such, it regularly calls <code>[oldContext reset];</code>. Without this line, it runs out of memory.</p> <p>I've discovered that by using this though, it's not returning the correct results. To test this, I commented out the data intensive code, leaving me with code which returned the <code>message</code> attribute, 51 of which are set to "Test" (confirmed by a separate NSFetchRequest).</p> <p>Using <code>[oldContext reset];</code> however, it only returns 6 results with the message set to "Test". This is the code I'm using:</p> <pre><code> NSFetchRequest *oldFetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *oldEntryEntity = [NSEntityDescription entityForName:@"Entry" inManagedObjectContext:oldContext]; [oldFetchRequest setEntity:oldEntryEntity]; [oldFetchRequest setFetchBatchSize:10]; [oldFetchRequest setIncludesPropertyValues:NO]; NSArray *entrys = [oldContext executeFetchRequest:oldFetchRequest error:&amp;error]; int totalEntries = [oldContext countForFetchRequest:oldFetchRequest error:nil]; int i = 0; while (i &lt; totalEntries) { @autoreleasepool { Entry *entry = [entrys objectAtIndex:i]; NSLog(@"message 1: %@", [entry valueForKey:@"message"]); [oldContext reset]; i++; } } </code></pre> <p>Any thoughts as to why it's not giving the 51 "Test" results it should do?</p>
    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