• 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
How to defer NSDocument:writeToFile:ofType ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to defer NSDocument:writeToFile:ofType ?


  • Subject: How to defer NSDocument:writeToFile:ofType ?
  • From: Manfred Lippert <email@hidden>
  • Date: Fri, 25 Jan 2002 19:19:57 +0100

Hi,

I have a "Multiple Document" based application. Now I have a very specific
need: I want to display a sheet to ask for some text (think of a password)
before the document actually will be saved.
For this purpose I tried to "defer" the writeToFile:ofType method. My
version of this method stores the parameters (filename and type), begins the
sheet ([NSApp beginSheet ...]) and returns NO, because sheets are
asynchronously running. After the sheet is finished, I tried to call [super
writeToFile:ofType] with the same parameters I got in the original call to
finish/redo the write operation.
Bad thing - it doesn't work. :-(

Two problems:

- It always "beeps" because my writeToFile method returns NO. But I cannot
return YES, because if NSApplication tries to save my document in a case of
"Quit" it will think it is saved correctly and will quit my application
before the sheet is handled.

- The deferred [super writeToFile:ofType] call doesn't write anything. No
file is created. If I do not defer it, it works.

I made the same thing with the readFromFile method and there it works
(Window opens, sheet is shown, after the sheet the document loads and shows
its contents in the window). But I could not begin the sheet directly in the
readFromFile method, but it works if I begin it in an overridden version of
"showWindows". Don't know if this is "perfect" but it works, and I always
have only one window per document.

So: A deferred "readFromFile" is working great here, but I cannot defer
"writeToFile".

Any ideas how this can be done?

Mani


  • Follow-Ups:
    • Re: How to defer NSDocument:writeToFile:ofType ?
      • From: "Erik M. Buck" <email@hidden>
  • Prev by Date: Re: reestablishing IBOutlets from initWithCoder ?
  • Next by Date: Re: app size
  • Previous by thread: Re: How can I standardize a path name? (Cocoa solution wanted)
  • Next by thread: Re: How to defer NSDocument:writeToFile:ofType ?
  • Index(es):
    • Date
    • Thread