On 17 Jul 2009, at 00:13 AM, Fritz Anderson <fri...@manoverboard.org> wrote:






> On 15 Jul 2009, at 6:14 PM, tmow...@talktalk.net wrote:






>> (gdb) po err


>> Program received signal EXC_BAD_ACCESS, Could not access memory.


>> Reason: KERN_PROTECTION_FAILURE at address: 0x00000000


>> 0x922e668c in objc_msgSend ()






(Earlier:)






>> NSError *err;


>> BOOL result = [moc save: &err];






> Are you sure moc isn't nil? Messages to nil yield zero-valued results,  


> so result would be NO, but err would not be set.


>


> And I'm sure you've checked it, but have you made sure result is NO?  


> Methods taking NSError ** don't return valid er
 ror objects unless they  


> have failed.


>


>       — F






Thank you very much for your persistence. Of course it turned out that the moc 
reference was nil.






The moc ivar was in my application controller which I was trying to set in the 
init method. Since both the application controller and the application delegate 
are instantiated from the main NIB the delegate was still nil when it was 
called.






I have removed it completely and just called the longer winded [[NSApp 
delegate] managedObjectContext] when I need it. I suppose I could have set the 
ivar in the awakeFromNib when all NIB objects are guaranteed to have been 
instantiated.






Being used to Java I tend 
 to forget about the object being instantiated via the NIB and to be careful 
with lifetime issues surrounding it. If some others read this and avoid the 
same silly mistake then it will have been useful.






Anyway once again thank you for your help.




Tim Mowlem

_______________________________________________

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