• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
How to customize NSDocument's error message 'The document ... could not be opened'
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: How to customize NSDocument's error message 'The document ... could not be opened'
      • From: mmalcolm crawford <email@hidden>
    • Re: How to customize NSDocument's error message 'The document ... could not be opened'
      • From: John Timmer <email@hidden>
  • Prev by Date: Newbie Q : show line numbers
  • Next by Date: Re: NSImageView and CoreData entity creation
  • Previous by thread: Re: Newbie Q : show line numbers
  • Next by thread: Re: How to customize NSDocument's error message 'The document ... could not be opened'
  • Index(es):
    • Date
    • Thread