• 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
makeDocumentForURL:nil withContentsOfURL:fileURL causing deletion
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

makeDocumentForURL:nil withContentsOfURL:fileURL causing deletion


  • Subject: makeDocumentForURL:nil withContentsOfURL:fileURL causing deletion
  • From: Trygve Inda <email@hidden>
  • Date: Sat, 08 Feb 2014 11:43:46 -0800
  • Thread-topic: makeDocumentForURL:nil withContentsOfURL:fileURL causing deletion

I am reading a document in the format of the old version of my app and
converting it to a new format. The old version is not a document at all but
is a fixed data file in /Application Support/MyApp/

MyDocument *untitledDoc = [[NSDocumentController sharedDocumentController]
makeDocumentForURL:nil withContentsOfURL:fileURL
ofType:kApplicationDocumentType error:&error];

if (untitledDoc)
{
  [untitledDoc makeWindowControllers];
  [untitledDoc showWindows];
  [untitledDoc setFileURL:nil];
  [[NSDocumentController sharedDocumentController] addDocument:(NSDocument
*)untitledDoc];
}



This works fine and I am able to migrate the data into a real NSDocument
subclass.

However, if I close the window (thus closing the document) and choose to not
save, the file package at fileURL is deleted.

Yikes!

How can I completely disassociate the fileURL from the new document that I
created. I want to treat fileURL as a template or stationary that is only
read from, and never written to.

[untitledDoc setFileURL:nil] does not seem to work to disassociate the
document from the source file.

Thanks,

Trygve



_______________________________________________

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: makeDocumentForURL:nil withContentsOfURL:fileURL causing deletion
      • From: Kevin Perry <email@hidden>
    • Re: makeDocumentForURL:nil withContentsOfURL:fileURL causing deletion
      • From: Jerry Krinock <email@hidden>
    • Re: makeDocumentForURL:nil withContentsOfURL:fileURL causing deletion
      • From: Markus Spoettl <email@hidden>
  • Prev by Date: Re: Can I Hide / Show an NSTextField / NSSecureTextField in Cocoa?
  • Next by Date: Re: Can I Hide / Show an NSTextField / NSSecureTextField in Cocoa?
  • Previous by thread: Re: Design pattern for bulk data handling
  • Next by thread: Re: makeDocumentForURL:nil withContentsOfURL:fileURL causing deletion
  • Index(es):
    • Date
    • Thread