How to customize NSDocument's error message 'The document ... could not be opened'
How to customize NSDocument's error message 'The document ... could not be opened'
- Subject: How to customize NSDocument's error message 'The document ... could not be opened'
- From: Kaspar Fischer <email@hidden>
- Date: Sun, 18 Sep 2005 14:45:22 +0200
Hi all,
In a subclass of NSPersistentDocument, I override
the method initWithContentsOfURL:ofType:error in
order to check whether the document's format
version is known. If it is an unrecognized version,
I create a suitable NSError and return nil.
The problem is that regardless of the NSError,
the same error message "The document ... could
not be opened" gets displayed. How can I change
this message to for instance "The document ...
could not be opened because it was created with
a newer version of this application"?
Thanks,
Kaspar
P.S. Here is my implementation of the
- (id)initWithContentsOfURL:(NSURL *)absoluteURL
ofType:(NSString *)typeName
error:(NSError **)outError
{
id result = [super initWithContentsOfURL:absoluteURL
ofType:typeName
error:outError];
id p = [self project];
int version = [[p valueForKey:@"fileFormatVersion"] intValue];
if (version != CURRENT_FILE_VERSION) {
NSDictionary *userInfo = [NSDictionary
dictionaryWithObject:@"Blabla"
forKey:NSLocalizedDescriptionKey];
*outError = [[NSError errorWithDomain:AIRS_ERROR_DOMAIN
code:UNKNOWN_FORMAT_VERSION
userInfo:userInfo] retain];
return nil;
}
return result;
}
_______________________________________________
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