Re: How to revert to an unedited document & window?
Re: How to revert to an unedited document & window?
- Subject: Re: How to revert to an unedited document & window?
- From: Brad Stone <email@hidden>
- Date: Wed, 30 Jun 2010 22:13:46 -0400
That was the suggestion I needed. Thank you. Here's what I did in the windowControler:
[doc removeWindowController:self];
[[self managedObjectContext] rollback];
[doc close];
and then I use my normal routine to reload the document.
On Jun 29, 2010, at 12:23 PM, Jerry Krinock wrote:
>
> On 2010 Jun 29, at 05:23, Brad Stone wrote:
>
>> Using [NSPersistentDocument revertToContentsOfURL:(NSURL *)inAbsoluteURLofType:(NSString *)inTypeName error:(NSError**)outError] works except the window closes and opens. If that didn't happen I'd be fine.
>
> Reverting a Core Data document is tricky. Apple's recommended methods are given here:
>
> http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/NSPersistentDocumentTutorial/04_Department/department.html#//apple_ref/doc/uid/TP40002832-SW6
>
> But you should also read these:
>
> http://www.cocoabuilder.com/archive/cocoa/161579-bug-in-nspersistentdocument-tutorial.html#161579
> http://www.cocoabuilder.com/archive/cocoa/174292-bug-nspersistentdocument-core-data-tutorial.html#174292
> http://www.cocoabuilder.com/archive/cocoa/177523-bug-nspersistentdocument-core-data-tutorial.html#177523
>
> Since "Revert" is not a major advertised feature of the app I was working on, after trying unsuccessfully to make it work for an hour or so, I gave up and implemented Revert to simply close and re-open the document. It's a little slow and ugly, but it works, and eliminates a branch of regression possibilities.
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> 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:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden