• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Releasing an NSManagedObjectContext
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Releasing an NSManagedObjectContext


  • Subject: Releasing an NSManagedObjectContext
  • From: "Jim Thomason" <email@hidden>
  • Date: Sun, 18 Mar 2007 18:34:23 -0500

I have a temporary NSManagedObjectContext, used for some migration,
and when I'm done using it, I want to release it. Standard stuff.

Unfortunately, my fetched NSManagedObjects still exist when I try to
release my context, and I sometimes get an exception:

2007-03-18 18:21:11.535 Debtinator[4711] An uncaught exception was raised
2007-03-18 18:21:11.541 Debtinator[4711] The NSManagedObject with
ID:0x382ff0 <x-coredata://2E18AFC3-F2C9-4A2E-9AA7-D46BA377FF3D/Frobnoz/p113>
has been invalidated.
2007-03-18 18:21:11.548 Debtinator[4711] *** Uncaught exception:
<NSObjectInaccessibleException> The NSManagedObject with ID:0x382ff0
<x-coredata://2E18AFC3-F2C9-4A2E-9AA7-D46BA377FF3D/Frobnoz/p113> has
been invalidated.

And it kills my app.

I seem to have had good luck by calling refreshObject:mergeChanges: on
all my registered objects when I'm done with the context, but I can't
truthfully say if that's really having an effect, or if it's just
coincidence. But, since I added those calls in, I only seem to crash
intermittently with the exception, instead of every single time.
Again, could just be coincidence.

So, I raise to you all....now what? What should I be looking for to
try and help isolate this issue? Is it a design flaw? Can I even
expect to do this with an NSManagedObjectContext, or do I need some
other approach/

I'd like to just release my objects when I'm done with them, but I'm
not retaining anything. I load up objects via fetchrequests or KVO
methods, but I don't retain anything. So how can I get rid of them?
The array from the fetch is autoreleased, and it's immutable, so I
can't go through and explicitly remove all the objects.

And I'm out of ideas. Any suggestions of how I can get rid of these
objects, or any other things I should be looking for in my managed
objects that could be causing this, I'd be greatly appreciative.

Thanks,

-Jim....
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Releasing an NSManagedObjectContext
      • From: Diederik Hoogenboom <email@hidden>
    • Re: Releasing an NSManagedObjectContext
      • From: Diederik Hoogenboom <email@hidden>
  • Prev by Date: Re: Renaming the "Cancel" button for NSOpenPanel
  • Next by Date: Completely mad caused by CIImage
  • Previous by thread: Re: NSDatePicker behaviour is odd when typing date
  • Next by thread: Re: Releasing an NSManagedObjectContext
  • Index(es):
    • Date
    • Thread