Re: Crashing resetting or releasing an NSManagedObjectContext [SOLVED]
Re: Crashing resetting or releasing an NSManagedObjectContext [SOLVED]
- Subject: Re: Crashing resetting or releasing an NSManagedObjectContext [SOLVED]
- From: Daniel Kennett <email@hidden>
- Date: Wed, 6 May 2009 14:01:21 +0100
*Sigh*
All this effort, and it turns out to be a one-line fix. Obviously.
[NSManagedObjectContext -setRetainsRegisteredObjects:YES]
Calling that on the context solves all the problems I was having, and
everything works perfectly now!
Thanks,
-- Daniel
_______________________
email@hidden
http://www.kennettnet.co.uk
Please include previous messages in any reply you send.
On 5 May 2009, at 09:46, Daniel Kennett wrote:
Thank you again for your helpful replies!
On a different note, when you comment out the "for (VetVisit" code,
does it still crash on a VetVisit, or does it crash on a
"Medication" object?
It still crashes on a VetVisit object.
I don't think I've solved the problem, but I have stopped it
crashing. Putting a breakpoint on [VetVisit -release] showed me
that NSFastEnumeration was releasing the object:
for (VetVisit *visit in [self vetVisits]) { // <-- Stack trace for
[VetVisit -release] comes from here
[visit className];
}
I solved the crash by doing this:
NSArray *visits = [[self vetVisits] allObjects];
for (VetVisit *visit in visits) {
[visit className];
}
... and now it works fine! The accessors for the vetVisits set are
just the ones made by the Core Data wizard thing - they're declared
like this:
@property (nonatomic, retain) NSSet* vetVisits;
... and implemented with this:
@dynamic vetVisits;
So, I've stopped the crash, but I'm thoroughly confused about what's
going on and think I'm just papering over the problem.
_______________________________________________
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