• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Versions browser, file access, revertToSaved
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Versions browser, file access, revertToSaved


  • Subject: Re: Versions browser, file access, revertToSaved
  • From: Martin Hewitson <email@hidden>
  • Date: Sat, 10 Mar 2012 11:47:48 +0100

On Mar 9, 2012, at 04:27 AM, Jerry Krinock wrote:

> On 2012 Mar 07, at 23:48, Martin Hewitson wrote:
>
>> I have an app which works with autosave and Versions browser.
>
> Oh, so you've implemented +[NSDocument autosavesInPlace]  ;)
>
>> I have a file-monitor in the app which reloads the document if it changes on disk.
>
> Great feature.  I've done that too.
>
>> For the reloading I was simply calling -revertDocumentToSaved: …
>
> If your document is Core Data, forget it.  You'll need to close and re-open.  Ugly, but at least it doesn't display any errors and you'll be able to ship sometime this year.
>
>> "The document “foo.txt” could not be saved. The file has been changed by another application."
>
>
> I've successfully beaten that monster a couple times with the following method.  It looks silly, but it works.  Try sprinkling one in during your reload somewhere…
>
> @implementation NSDocument (SyncModDate)
>
> - (void)syncFileModificationDate {
>    NSFileManger* fm = [NSFileManager defaultManager] ;
>    NSDictionary* fileAttributes = [fm attributesOfItemAtPath:[[self fileURL] path]
>                                                        error:NULL] ;
>    NSDate* newDate = [fileAttributes objectForKey:NSFileModificationDate] ;
>    [self setFileModificationDate:newDate] ;
> }
>
> @end

Superb. That fixed it. Thanks!

Martin

>
> I think I got the idea from here:
>
> http://stackoverflow.com/questions/380076/manual-core-data-schema-migration-without-document-changed-warning
>
>
> _______________________________________________
>
> 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

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Martin Hewitson
Albert-Einstein-Institut
Max-Planck-Institut fuer
    Gravitationsphysik und Universitaet Hannover
Callinstr. 38, 30167 Hannover, Germany
Tel: +49-511-762-17121, Fax: +49-511-762-5861
E-Mail: email@hidden
WWW: http://www.aei.mpg.de/~hewitson
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~






_______________________________________________

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


References: 
 >Versions browser, file access, revertToSaved (From: Martin Hewitson <email@hidden>)
 >Re: Versions browser, file access, revertToSaved (From: Jerry Krinock <email@hidden>)

  • Prev by Date: updating old nsapplescript methods
  • Next by Date: Calling objc_getAssociatedObject in -finalize.
  • Previous by thread: Re: Versions browser, file access, revertToSaved
  • Next by thread: Dynamic NSMenuItems with default param
  • Index(es):
    • Date
    • Thread