Good morning,

I’ve got a scenario where I need to prompt the user during reading of a 
document in my OS X document-based application. There have been some minor 
changes to the format of my document files, and I need to support opening 
documents saved in the old format and prompting the user to convert the file to 
the new format. The old and new formats use the same file extension/type info, 
so I need to actually open the file and check the internals to determine if it 
is the old format or the new.

My document reading happens in readFromData:ofType:error:. In that method I’ve 
added code which determines the format and, if it’s the old format, creates and 
displays an NSAlert to ask the user if they want to update the document 
in-place or create a copy.

This seems to work in initial testing — the alert displays — but I get a 
message in the console telling me that “NSAlert is being used from a background 
thread, which is not safe. This is probably going to crash sometimes. …” 
Presumably this is because I have overridden 
+canConcurrentlyReadDocumentsOfType: to return YES for my documents, resulting 
in document reading happening on a background thread. Changing 
+canConcurrentlyReadDocumentsOfType: to return NO makes the warning message go 
away.

My question is, is there a more appropriate or “correct” place or pattern for 
me to do this checking of the document format and prompting the user, instead 
of in readFromData:…? Or am I doing this correctly, and I just can’t read 
documents concurrently because I may need to prompt the user during reading of 
a document?

Thanks!
_______________________________________________

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