Re: Crash in NSPersistentDocument writeToURL:ofType:forSaveOperation:originalContentsURL:error:
Re: Crash in NSPersistentDocument writeToURL:ofType:forSaveOperation:originalContentsURL:error:
- Subject: Re: Crash in NSPersistentDocument writeToURL:ofType:forSaveOperation:originalContentsURL:error:
- From: Quincey Morris <email@hidden>
- Date: Wed, 26 Jan 2011 22:32:36 -0800
On Jan 26, 2011, at 21:41, Jim Thomason wrote:
> It can be trivially repaired by just setting *error = nil upon entry
> into the method. That wipes out whatever is dangling around and then
> everything behaves correctly. But that's a dippy fix - I should be
> able to assume that the error pointer that Cocoa is generating for me
> is valid and I can just work with it w/o explicitly wiping it out
> first, right?
Well, no. 'error' is an OUTPUT ONLY pointer. Specifically, on entry:
1. 'error' is either NULL (no error information should be returned), or a valid address to return a NSError* into, if an error occurs
2. '*error' is trash (<-- subtle, but important)
On output:
1. If 'error' was NULL, you of course don't try to return anything
2. If 'error' is non-null and you return NO, '*error' must point to a valid NSError object that you created
3. If 'error' is non-null and you return YES, '*error' does not need to be preserved (you can set it whatever trash you want) (<-- subtle but important)
If I read your post correctly, you're trying to interpret '*error' as input, which is a no-no.
_______________________________________________
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