Re: NSError and user-cancel induced "errors"
Re: NSError and user-cancel induced "errors"
- Subject: Re: NSError and user-cancel induced "errors"
- From: "Timothy J. Wood" <email@hidden>
- Date: Thu, 29 Sep 2005 15:30:01 -0700
On Sep 29, 2005, at 2:55 PM, Ali Ozer wrote:
Tim,
There is NSUserCancelledError which is for this purpose. It's
specially treated by the NSError handling machinery in NSDocument/
NSApplication not to put up a panel.
Ali
Hrm... I totally missed that. It's 10.4 only, so we'll still
need to do our own thing for 10.3 for a while longer.
The comments in NSResponder.h don't indicate if this has to be the
immediate error or if it checks the underlying errors too. I will be
fairly common to have a method that might fail for either a 'real'
reason or a user-cancelled reason. In this case, another method
calling it shouldn't have to check if the returned domain/code are
the special cancelled combination (and then avoid stacking its error
on top of the cancel).
In OmniFoundation I've taken the approach of putting a special key
in the user info for user-cancel marking. Then, I have a category
method:
/*" Returns YES if the receiver or any of its underlying errors has a
user info key of OFUserCanceledActionErrorKey with a boolean value of
YES. "*/
- (BOOL)causedByUserCanceling;
{
NSError *error = self;
while (error) {
NSDictionary *userInfo = [error userInfo];
if ([[userInfo valueForKey:OFUserCanceledActionErrorKey] boolValue])
return YES;
error = [userInfo valueForKey:NSUnderlyingErrorKey];
}
return NO;
}
How does NSApplication/NSDocument handle this?
-tim
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden