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

  • Home
  • SEARCH
  • 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 6631819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:36:00+00:00 2026-05-25T22:36:00+00:00

I have three classes, A, B and C. A is the main class. When

  • 0

I have three classes, A, B and C. A is the main class.

When the user wants to see the list of all objects that were purchased, Class B is called from A and shows the list of objects in a core data entity.

Inside class B, the user can buy new objects (in-app purchase). When the user wants to buy another object, class C is called.

When class C is called, a new object is created on the core data entity using

anObject = [NSEntityDescription insertNewObjectForEntityForName:@"Objects" inManagedObjectContext:context];

this object is then assigned to a local reference on Class C, using something like

self.object = anObject;

this object variable was declared like this:

.h
MyObjects *object;
@property (nonatomic, retain) MyObjects *object;

and @synthesized on .m

MyObjects is a core data class representing the entity.

In theory, object will retain anything assigned to it, so the line self.object = anObject I typed previously will retain anObject reference on self.object, right?

The problem is that when I try to access self.object in the same class after buying the new object, I receive an error “CoreData could not fulfill a fault for XXX”, where XXX is exactly self.object.

At no point in the code there’s any object removal from the database. The only operation to the database I could identify was a saving operation done by another class moments before the crash. The save is done by something like

if (![self.managedObjectContext save:&error]) ...

Is there any relation? what may be causing that?

  • 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-25T22:36:01+00:00Added an answer on May 25, 2026 at 10:36 pm

    CoreData manages the lifetime of managed objects and you should not retain and release them. If you want to keep a reference to the object so that it can be retrieved later then you have to store the object’s id (obtained using -[NSManagedObject objectID]). Then use that to retrieve the object later using -[NSManagedObjectContext objectWithID:].

    Make sure you understand about CoreData faulting. Read the documentation.

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

Sidebar

Related Questions

I have three classes that all have a static function called 'create'. I would
I have a base class that three classes inherit from. Whenever these child classes
I have three classes; Classes A and B both reference class C . How
Say I have three classes: class X{}; class Y{}; class Both : public X,
If I have three classes class A class B extends A class C extends
I have several small classes that are all peers of each other declared and
Summary I have three classes: Account SpecialAccount (inherits from Account ) Profile (0..1 relationship
Say I have two classes One, the Foo class, interfaces with the user, and
I have three classes that will each return a slightly different result. // interfact
Suppose I have three classes. It is valid to instantiate A, but there are

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.