Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6616107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:32:35+00:00 2026-05-25T20:32:35+00:00

Cheers, I’m experiencing a problem with core data, I guess I’m just looking in

  • 0

Cheers,

I’m experiencing a problem with core data, I guess I’m just looking in the wrong direction again.

My managedObjectContext will return an empty NSSet if I call registeredObjects on it. If I execute a fetch beforehand however, it will return the same objects that as the fetch did just a moment ago.

There’s no multithreading going on.

Here’s what I do:

[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:&ftchError];

NSLog(@"Fetch returned %i objects.", [fetchResults count]);

[request release];

// Done fetching...

NSArray *allObjects = [[managedObjectContext registeredObjects] allObjects];

NSLog(@"Context contains %i objects...", [allObjects count]);

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.

Note that I am at no point commiting or otherwise changing the contexts contents.

Do I need to force the context into refreshing itself first? I’ve never done this before though and I don’t recall registeredObjects failing on me like this on other occasions in the first place.

Any suggestions appreciated!
Toastor

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:32:35+00:00Added an answer on May 25, 2026 at 8:32 pm

    You may be confused about what registeredObjects means. This is the set of objects that are currently in the NSManagedObjectContext. This is not the set of objects in the store, just the ones in the context. If you haven’t fetched or otherwise registered the objects in the context, then they won’t be in registeredObjects.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just a quick one... How do I determine what interfaces a type implements? Cheers
Hello I wanna compare two lists like this a=[1,2] b=10,20] compare(a,b) will return True
Cheers every! I want to store some data in memory in a structure, or
Just wondering what's a better way to write this query. Cheers. SELECT r.user_id AS
Just a quick one. What am I doing wrong here? $(#content a:not(target=_blank)).live(click, function(){ alert(You
Cheers, I like strict typing in C. Therefore, I don't want to store a
How would anyone convert a array based tree into per-order? The array contains: Cheers
Im wondering how I can display a Euro symbol in UTF-8 Format ? Cheers
Is it possible to shutdown Windows programmatically with Java? Cheers
Cheers, I ran into this chunk of code in Programming Game AI by Example:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.