Hi,

when using UIDocument, reading and writing the document is done asynchronously 
in a separate thread. But there's one thing I don't understand: how is that 
supposed to be used with non-thread-safe models? In my opinion most 
straight-forward implemented models are _not_ thread-safe.
If you have the common case of a non-thread-safe model - is there an easy way 
to let UIDocument do reading/writing synchronously at the main thread? Or are 
we supposed to serialize every (!) modification of the model in a 
performAsynchronousFileAccessUsingBlock call?

Initially reading the document (triggered by openWithCompletionHandler) is 
usually not a problem. The user can not work with the model before it has been 
loaded. The problems begin when writing the document: the document write 
methods are called asynchronously, so the model is accessed at this time, but 
the user can do things at the same time in parallel through the UI and modify 
the model at the same time as it is saved - a big source for unpredicted 
behaviour, data-loss, crashes ...

The documentation for performAsynchronousFileAccessUsingBlock only mentions 
accessing the "document" (assuming this means the document's file?). But I 
think serializing the file access is not enough; accessing the "in-memory" 
model must also be serialized. Or did I miss something?

Regards,
Mani


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to