Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6343263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:24:15+00:00 2026-05-24T20:24:15+00:00

In my NSDocument based app, my documents are to be associated with directories (they

  • 0

In my NSDocument based app, my documents are to be associated with directories (they are an index of the directory)

I want to be able to open/save documents according to the following use case:

  1. Opening a directory:
    a) if there is a .myapp file in the folder, open it
    b) else look if there is HASH-OF-PATH-basename.myapp file in ~/Library/Application Support/MyApp and open that
    b) else create a new document in memory

  2. Opening an xxx.myapp file, as normal

  3. Save / Autosave
    a) if source of current doc was 1b, 1c, or 2 save file to ~/Library/Application Support/MyApp/HASH-OF-PATH-basename.myapp
    b) if source of current doc was 1a, save to that .myapp file

  4. Save As / Save To
    b) save an xxxxx.myapp to wherever the user specifies

The obvious thing seemed to be just to implement readFromURL:ofType:error:L and writeToURL:ofType:forSaveOperation:originalContentsURL:error: and switch URL as necessary based on what the saveoperation was.

This works in that I can open files and folders, and when I save an open folder my file is saved to Application Support, but then after writeToURL:ofType:forSaveOperation:originalContentsURL:error an error is raised and a dialog shown with the following error:

NSDocument could not delete the temporary item at
file://localhost/private/var/folders/6P/6PNpIB-6HreGE+Ikqf5dWU+++TI/
-Tmp-/TemporaryItems/(A%20Document%20Being%20Saved%20By%20MyApp%203)
/SomeDirectory. 
Here's the error:
Error Domain=NSCocoaErrorDomain Code=4 UserInfo=0x200583a00 
"“SomeDirectory” couldn’t be removed."
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T20:24:15+00:00Added an answer on May 24, 2026 at 8:24 pm

    This turned out to be fairly easy to resolve.

    I overrode saveToURL:ofType:forSaveOperation:error: and did the url & type swapping based on SaveOperation type there.

    Now things are working as expected.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a straightforward NSDocument -based Mac OS X app in which I am
I've successfully implemented a NSDocument class in my Cocoa App which is also able
I'm trying to display HTML source code in my NSDocument based application. However, it
I'm new to Mac programming and I'm working on a document-based application. My NSDocument
I have an NSDocument which has the following structure: @interface MyDocument : NSDocument {
I have a document-based Cocoa app. During runtime, I load an additional nib from
I have a NSDocument based application with a nib that represents the visual document.
I have an NSDocument subclass with two NSWindowControllers corresponding to 2 different xib. Following
I'm doing some crazy multiple documents inside a single window stuff with the document-based
Based on several good articles I have been able to successfully create a few

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.