title: NSManagedObjectContext's registeredObjects won't return anything unless a fetch is executed beforehand
body: <p>Cheers,</p>
  
  <p>I'm experiencing a problem with core data, I guess I'm just looking in the wrong direction again.</p>
  
  <p>My managedObjectContext will return an empty NSSet if I call <code>registeredObjects</code> on it. If I execute a fetch beforehand however, it will return the same objects that as the fetch did just a moment ago.</p>
  
  <p>There's no multithreading going on.</p>
  
  <p>Here's what I do:</p>
  
  <pre><code>[self setupContext]; // This will set up managedObjectContext, which is a property of this class
  
  // Fetching...    
  
  NSFetchRequest *request = [[NSFetchRequest alloc] init];
  NSEntityDescription *foo = [NSEntityDescription entityForName:@"Foo" inManagedObjectContext:managedObjectContext];
  [request setEntity:foo];
  
  NSError *fetchError = nil;
  NSArray *fetchResults = [managedObjectContext executeFetchRequest:request error:&amp;ftchError];
  
  NSLog(@"Fetch returned %i objects.", [fetchResults count]);
  
  [request release];
  
  // Done fetching...
  
  NSArray *allObjects = [[managedObjectContext registeredObjects] allObjects];
  
  NSLog(@"Context contains %i objects...", [allObjects count]);
  </code></pre>
  
  <p>The store contains 30 objects. If I run the code above, both NSLogs will report five objects. If I remove the fetch part between the two comments, it will report zero objects for the whole context.</p>
  
  <p>Note that I am at no point commiting or otherwise changing the contexts contents.</p>
  
  <p>Do I need to force the context into refreshing itself first? I've never done this before though and I don't recall <code>registeredObjects</code> failing on me like this on other occasions in the first place.</p>
  
  <p>Any suggestions appreciated!
  Toastor</p>