Thanks for the reply Graham. It sounds as if I would have to have control over
the framework to do as you suggest, but I don't have access to the framework
source.
My understanding of what the framework does is:
[delegate saveData];
if (dataHasBeenSaved) {
do stuff
} else {
do different stuff
}
So if my delegate method saveData uses the sheet to save, it will return from
the saveData method immediately, no matter what I do. I do have the file saving
code in the completion block of the sheet, but by then it's too late - the
framework thinks the data wasn't saved.
I'm afraid I can't see a way to refactor that so that saveData doesn't return
until the save operation is complete, and I can't see how the framework could
work properly without waiting for the completion of the save operation.
Maybe I'm missing something obvious about the way this is supposed to work (I'm
still rather new to all this), or some other option. I did try to have a look
at the document saving system, since it seems to be able to wait for the open
documents to be saved on quit before deciding if the application should quit,
but I didn't fully understand that, and I think it may operate in a different
way than what I need.
Regards
Ken
PS sorry about the double posting before - I'm using the web version of mobile
me at the moment, and it seems to screw up every time I use it :(
On 14 Feb, 2011,at 10:12 PM, Graham Cox <[email protected]> wrote:
You need to factor your code so that you don't require the sheets to "block".
That isn't how they work. Instead, while the sheet is displayed, the event loop is run
normally and will run the sheet modally while running everything else (like other
documents) as normal. The user can switch away from the document displaying the sheet and
come back to it later if they want.
The point is that when the sheet ends (the user clicks OK or Cancel) the
completion method (or block) is run, and it is this code that does the actual
file saving. The purpose of the sheet is not only to choose the file name and
location but to trigger the save itself. Rearranging your code so that the file
save is triggered in this way should be straightforward - just call the save
method from the sheet's completion method.
--Graham
_______________________________________________
Cocoa-dev mailing list ([email protected])
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]