To perform Core Data migration automaticlly, my overridden 
configurePersistentStoreCoordinatorForURL:ofType:modelConfiguration:storeOptions:error:,
 archives the original document by invoking -[NSFileManager moveItemAtPath:::], 
appending a tilde (~) to its name, then migrates the document to a new 
store/file, and similarly moves the new file back to the original name and 
opens it.  Thus the user sees nothing extraordinary unless they notice the 
tilde-fied file appear in Finder.  And all works OK if the user stays within my 
application.

But if the user should, for some reason, activate Finder and click on the 
tilde-fied document, some observer notices and sends my document a setFileURL:, 
setting it back to that of the original store, which now has the tilde.  Poof!  
A tilde appears in the window title.  And, of course, any future operations 
involving the persistent store result in an error since it's now trying to 
access the old store which is built on the old data model.  See call stack 
below.

Presumably, these -_handleDocumentFileChanges: methods are implementing the 
NSDocument/Controller Magic File Watcher which changes the window title if the 
user externally changes the filename of an open document.  But it seems to not 
know about my migration.  How can I tell it?

I can't find any related methods or documentation regarding this Magic File 
Watcher in the Cocoa Document architecture.  Does anyone where it might have 
some hooks?  I'm afraid that it stores an inaccessible file alias under the 
hood, independent of the fileURL which of course is accessible.

Thanks,

Jerry Krinock

Here is the call stack if I debug/break when setFileURL: gets set back to the 
tilde-fied file:

#0      0x0012d949 in -[MyDocument setFileURL:] at MyDocument.m:3867
#1      0x90932c9d in _NSSetObjectValueAndNotify
#2      0x969ef20b in -[NSDocument _handleDocumentFileChanges:]
#3      0x928c0738 in -[NSArray makeObjectsPerformSelector:withObject:]
#4      0x969ef0f8 in -[NSDocumentController _handleDocumentFileChanges:]
#5      0x9092dadd in __NSFireDelayedPerform
#6      0x9289076b in __CFRunLoopRun
#7      0x9288e0f4 in CFRunLoopRunSpecific
#8      0x9288df21 in CFRunLoopRunInMode
#9      0x987110fc in RunCurrentEventLoopInMode
#10     0x98710ded in ReceiveNextEventCommon
#11     0x98710d36 in BlockUntilNextEventMatchingListInMode
...

_______________________________________________

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

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

Reply via email to