On Dec 10, 2011, at 16:51 , C.W. Betts wrote:

> - (BOOL)readFromFileWrapper:(NSFileWrapper *)fileWrapper ofType:(NSString 
> *)typeName error:(NSError **)outError
> {
>       int chosen = [self showMemoryCardChooserForFile:[fileWrapper filename]];
>       if (chosen == 0) {
>               return NO;
>       } else {
>               [ConfigurationController setMemoryCard:chosen toPath:[[self 
> fileURL] path]];
>               //TODO: make this return YES so that "File Can't be Opened" 
> dialog box doesn't pop up, but the window itself doesn't stay on the screen.
>               return NO;
>       }
> }
> It is returning NO because if I return YES, after the modal window pops up, a 
> button is pressed that will dismiss the modal dialog, the window pops up 
> again, non-modal this time, making the button that would have closed it not 
> work. But because I return NO, a message pops up that says the file could not 
> be opened. I want to fix that if at all possible.

Incidentally, this code is seriously wrong, assuming you didn't leave anything 
out for brevity's sake. If you return NO, you *must* create a NSError object 
and return it via the outError parameter. Without the returned error object, 
your app is likely to crash.

If you want to return NO and also prevent the document handling mechanism from 
displaying any kind of error, then you can return a NSError with domain 
NSCocoaErrorDomain and code NSUserCancelledError. That suppresses the 
framework's error reporting.




_______________________________________________

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