• 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: NSDocument: Read-only types and autosavesInPlace
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSDocument: Read-only types and autosavesInPlace


  • Subject: Re: NSDocument: Read-only types and autosavesInPlace
  • From: Kevin Perry <email@hidden>
  • Date: Fri, 22 Jul 2011 10:25:05 -0700

On Jul 22, 2011, at 9:16 AM, Daniel Vollmer wrote:

> Hello,
>
> I'm trying to add autosavesInPlace support to my NSDocument-based Application. It supports a read-only type that is internally converted (as suggested in https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Documents/Tasks/FAQ.html#//apple_ref/doc/uid/20000954-1081265-BAJFDEGD) to my writable type.
>
> The viewer- and editor-roles are set correctly in the application's plist, +writableTypes also returns only what I can write. For reference, I can read .txt and read/write .wowplot.
>
> Now, this seems to interact badly with autosavesInPlace: YES. The following happens:
> 1) I open a document of the read-only type (.txt)
> 2) I convert this as suggested above to my writable type, using setFileType and setFileURL
> 3) I modify the document
> 4) I attempt to close the document
> 5) Now the autosave-Machinery jumps into action and I get the following error:
> [ERROR] genstore_storage.c:GSAddPathAsGeneration:980  copyfile "/Volumes/Seerose/Users/maven/Desktop/110720 225338.wowplot" to "/Volumes/Seerose/Users/maven/Library/Autosave Information/2521980F-37BC-4E21-AF6A-001BE638AEFC.genstore.noindex/.genstore_staging/OUyU4Xi/staged" failed with error 2 (No such file or directory)
>
> The errors make sense, as the file under that name never existed.
>
> Now I'm stuck in-between a rock in a hard place:
> If I change the type, autosavesInPlace tries to duplicate a non-existent file (because I modified the fileURL); if I don't change the type, NSDocument will ask me to write a file of a type I cannot support.
>
> Any ideas?


There's a tidbit in the AppKit release notes regarding this (Look for "File Type Fixing in -[NSDocument saveToURL:ofType:forSaveOperation:completionHandler:]").

While it doesn't say it right out, it suggests that you should give responsibility for changing to file URL to NSDocument. All you need to do is change the file type and NSDocument will take care of the file URL and avoid this error. (Note: you won't get this behavior if you're overriding the old -saveToURL:ofType:forSaveOperation:error: method.)

The documentation you linked to has not been updated to reflect this. Please file a radar against the documentation to get this updated.

-KP_______________________________________________

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: NSDocument: Read-only types and autosavesInPlace
      • From: Daniel Vollmer <email@hidden>
References: 
 >NSDocument: Read-only types and autosavesInPlace (From: Daniel Vollmer <email@hidden>)

  • Prev by Date: Re: Determine architecture of a running application
  • Next by Date: Re: NSDocument: Read-only types and autosavesInPlace
  • Previous by thread: NSDocument: Read-only types and autosavesInPlace
  • Next by thread: Re: NSDocument: Read-only types and autosavesInPlace
  • Index(es):
    • Date
    • Thread