*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

 _______________________

   dan...@kennettnet.co.uk
   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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to