• 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
Upgrading NSDocument format, best practice
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Upgrading NSDocument format, best practice


  • Subject: Upgrading NSDocument format, best practice
  • From: Markus Spoettl <email@hidden>
  • Date: Wed, 16 Sep 2009 15:52:16 +0200

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 (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Upgrading NSDocument format, best practice
      • From: "I. Savant" <email@hidden>
  • Prev by Date: Re: Last Apple Help question (hopefully)
  • Next by Date: Re: Upgrading NSDocument format, best practice
  • Previous by thread: Re: NSNotificationQueue : NSPostingStyle : Definitions for Dummies
  • Next by thread: Re: Upgrading NSDocument format, best practice
  • Index(es):
    • Date
    • Thread