Re: NSError in NSDocument readFromURL
Re: NSError in NSDocument readFromURL
- Subject: Re: NSError in NSDocument readFromURL
- From: Quincey Morris <email@hidden>
- Date: Sun, 12 Jul 2009 20:49:43 -0700
On Jul 12, 2009, at 15:50, Konrad Windszus wrote:
If I set an NSError in the method readFromURL of my NSDocument, I am
not able to overwrite the NSLocalizedDescriptionKey.
...
Unfortunately only the strings of the keys
NSLocalizedFailureReasonErrorKey and
NSLocalizedRecoverySuggestionErrorKey are displayed together with a
standard error text. My own localizedDescription ("Description") is
not displayed. Instead I got the standard error text "The document
<xyz> could not be opened. FailureReason RecoverySuggestion". Is
this a bug, that the string with the key NSLocalizedDescriptionKey
is always overwritten before displayed or not displayed at all, if
set in readFromURL or is this feature somewhere documented? I could
not find anything regarding this at apple.
No, the NSError object you create is just fine, but
NSDocumentController (which causes the error alert to be displayed)
*always* makes the alert say that the document could not be opened.
If you want to display your own description, you need to display your
own alert before returning from readFromURL:... (using [NSApp
presentError:], usually), then return an error with
domain=NSCocoaErrorDomain and code=NSUserCancelledError, to suppress
NSDocumentController's alert.
_______________________________________________
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