Hello,

I have an NSDocument that reads old-format files which it does no longer write. When loading such an old format file, the app warns the user about the format-change and the fact the file can't be read by older versions once saved with the new one.

Unfortunately, producing files in a compatible format is not possible. I know...

The problem is most warning messages are quickly dismissed unread. So in order to avoid that the user accidentally overwrites old-format files he wanted to keep, I make sure the he has to pick a filename when he decides to save the freshly upgraded document.

To do so I set -fileURL to NIL and tell the document it has been loaded from a different file using -updateChangeCount:

- (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName error: (NSError **)outError
{
    [... read data and upgrade if necessary ...]

    if (thisWasAnOldFormat) {
        [self setFileURL:nil];
        [self updateChangeCount:NSChangeReadOtherContents];
    }
}

This works exactly as expected, the file is unnamed and changed, so whatever happens a filename must be chosen. The user would clearly prefer a solution more transparent than this, but I'd rather not convert data he's not willing to upgrade just yet.

I guess my question is, is this the way to do it? Are there alternatives?

Regards
Markus
--
__________________________________________
Markus Spoettl

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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