• 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
Re: Crashing resetting or releasing an NSManagedObjectContext
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Crashing resetting or releasing an NSManagedObjectContext


  • Subject: Re: Crashing resetting or releasing an NSManagedObjectContext
  • From: Alexander Spohr <email@hidden>
  • Date: Mon, 4 May 2009 19:59:01 +0200

You are still having the same error.

All your objects in the relationships are fetched. Therefore they are owned by the NSManagedObjectContext. You kill the NSManagedObjectContext by releasing it. After that point you are not allowed to touch any of its fetched objects. But you hand them out inside the NSDictionary.

Pleas reconsider my first tip and let the calling method create the NSManagedObjectContext. Use that to fetch all your objects, process them and _then_ kill your NSManagedObjectContext.

An NSManagedObject can not live without its NSManagedObjectContext. The NSManagedObjectContext ist the bucket that holds it. You can not take it out and throw the bucket away. Will not work.

	atze



Am 01.05.2009 um 10:24 schrieb Daniel Kennett:


NSManagedObjectContext *context = [[NSManagedObjectContext alloc] init];

Pet *pet = [KNClarusQuickDocumentParser petAtURL:url inContext:context];

NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];


[dict setValue:[[[pet valueForKey:@"name"] copy] autorelease] forKey:@"name"];
[dict setValue:[[[pet valueForKey:@"birthday"] copy] autorelease] forKey:@"birthday"];
// More copying of strings and dates
[..]
[dict setValue:[[[pet valueForKey:@"pertinentActions"] copy] autorelease] forKey:@"pertinentActions"]; // <--- Here


[context release];

^^^^^^^^^^^^^^^^^ this release kills all fetched objects.

return [dict autorelease];

^^^^^^^^^^^^^^^^^ this dict contains dead objects.


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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: Crashing resetting or releasing an NSManagedObjectContext
      • From: Keary Suska <email@hidden>
References: 
 >Re: Crashing resetting or releasing an NSManagedObjectContext (From: Daniel Kennett <email@hidden>)

  • Prev by Date: Re: Cocoa Drawing
  • Next by Date: Re: Cocoa Drawing
  • Previous by thread: Re: Crashing resetting or releasing an NSManagedObjectContext
  • Next by thread: Re: Crashing resetting or releasing an NSManagedObjectContext
  • Index(es):
    • Date
    • Thread