On Jul 29, 2012, at 10:53 , Pascal Harris <[email protected]> wrote:

> 2.  If the document fails to open then I want to copy it to a new location, 
> with a new extension (see above).  This fails.  I can't think why!

On Jul 29, 2012, at 11:47 , Pascal Harris <[email protected]> wrote:

> Good point - I've now fixed this.  That still doesn't explain why the window 
> stays open though.  When I fix this problem, it doesn't provide an error 
> message to the user either.  Perhaps this is connected to the reason that the 
> window opens anyway, even if the data can't be read.

The implication of your two statements here (no error message, no creation of 
the copy) is that 'loadTextViewWithInitialData' is in fact returning YES.

Returning NO from 'readFromData:' really does cause NSDocumentController to 
display an alert (except when the returned error is 
NSCocoaErrorDomain/NSUserCancelledError, which is a standard way of preventing 
it from complaining). Since you've already acknowledged that the code you 
posted is not the actual code, we have to assume you have a code path through 
your real code that's returning YES.

>        NSMutableDictionary *errorDetail = [NSMutableDictionary dictionary];
>        [errorDetail setValue:@"This file is corrupted and could not be read." 
> forKey:NSLocalizedDescriptionKey];
> 
>        *outError = [NSError errorWithDomain:NSOSStatusErrorDomain code:1 
> userInfo:
>                 errorDetail];

You should always check that 'outError' isn't NULL before dereferencing it. The 
NSError** outError pattern doesn't require outError to be non-NULL. I suspect 
that NSDocumentController never passes NULL, but it would be best to get used 
to avoiding the assumption.


_______________________________________________

Cocoa-dev mailing list ([email protected])

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

This email sent to [email protected]

Reply via email to