Re: How to revert to an unedited document window?

2010-06-30 Thread Brad Stone
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 (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/cocoa-dev%40softraph.com
 
 This email sent to cocoa-...@softraph.com

___

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


How to revert to an unedited document window?

2010-06-29 Thread Brad Stone
I have a subclassed windowController that has an associated core data 
managedObject called note, a managedObjectContext and a NSPersistendDocument. 
 Sometimes I need to reset everything back to the last time the doc was saved 
and make the doc clean (isDocumentEdited == NO) so that when I close it the 
documentController doesn't ask me if I want to save changes.

managedObjectContext rollback does restore everything to the last save but I 
can't get the document to be unEdited.  Using [window setDocumentEdited:NO] or 
[windowController setDocumentEdited:NO} (which I know I shouldn't call) both 
don't work.

Do I have to reset the persistendDocument somehow?

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.

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

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


Re: How to revert to an unedited document window?

2010-06-29 Thread Jerry Krinock

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 (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