• 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
Re: Why does NSDocument not care about saving Viewer-role document types
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why does NSDocument not care about saving Viewer-role document types


  • Subject: Re: Why does NSDocument not care about saving Viewer-role document types
  • From: Markus Spoettl <email@hidden>
  • Date: Mon, 11 Jun 2012 08:54:10 +0200

On 6/11/12 1:48 AM, Graham Cox wrote:
I believe the 'role' settings are only used by Core Data (if I'm wrong, I'm sure
someone will correct me).

I've run into the same issue. I've had to override -setFileURL: and at that
point "upgrade" the URL to have the appropriate extension so that the modern
version of the file is later written out with the right extension. It doesn't
overwrite the old one because the extension change is seen as a new filename.

When you -saveDocumentAs:, the role seems to be used to determine whether or not to present an accessory view with a file-type selector. With multiple editor roles you get the accessory, with only one you don't. So clearly it's being used by the framework.

I worked around it by checking in -saveDocument: if the file type the document currently has is one we can actually save. If not, I call -saveDocumentAs: on super, which suggests the original file path with the new location. In my app the user gets a warning about the format change when opening an old document, so all this doesn't come as a surprise.

I tried using -setFileURL: with a changed file extension but that has the disadvantage of potentially overwriting a file that's already using that name without any warning (however slim the chances of such a file existing are).

Regards
Markus
--
__________________________________________
Markus Spoettl
_______________________________________________

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

References: 
 >Why does NSDocument not care about saving Viewer-role document types (From: Markus Spoettl <email@hidden>)
 >Re: Why does NSDocument not care about saving Viewer-role document types (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: QTKit from UNIX app?
  • Next by Date: Defining subclasses at run time
  • Previous by thread: Re: Why does NSDocument not care about saving Viewer-role document types
  • Next by thread: NSDocument -canAsynchronouslyWriteToURL::: never called
  • Index(es):
    • Date
    • Thread