• 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: Multithreaded Coredata save in Lion
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Multithreaded Coredata save in Lion


  • Subject: Re: Multithreaded Coredata save in Lion
  • From: Jerry Krinock <email@hidden>
  • Date: Sun, 31 Jul 2011 13:26:47 -0700

On 2011 Jul 31, at 11:29, Quincey Morris wrote:

> The problem is that I can't think of any reason why it would be acceptable for an application to save a document without the user's consent (it takes away the user's ability to, at the very least, close the document *without* saving changes, which turns the application into a ticking time bomb) ...
>
> OR
>
> ... (if you have a genuine justification for taking the Save metaphor away from the user) why you would use NSPersistentDocument at all, rather than using Core Data directly, including [NSManagedContext save:] to push your changes to the persistent store.

OR is good advice.  Be careful if you want to mix these metaphors.  Invoking [NSManagedObjectContext save:] will cause the dreaded "file has been changed by another application" warning if user subsequently dirties and saves it. You can usually fix that by defining in your document and invoking this method:

- (void)syncFileModificationDate {
    NSFileManager* fm = [NSFileManager defaultManager] ;
    NSDictionary* fileAttributes = [fm fileAttributesAtPath:[[self fileURL] path]
                                               traverseLink:NO] ;
    NSDate* newModificationDate = [fileAttributes objectForKey:NSFileModificationDate] ;
    [self setFileModificationDate:newModificationDate] ;
}

But I would try Mike Abdullah's idea first.  When messing with the Cocoa document architecture, the lower level at which you mess, the more trouble you're going to have.

_______________________________________________

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: 
 >Multithreaded Coredata save in Lion (From: Jim Thomason <email@hidden>)
 >Re: Multithreaded Coredata save in Lion (From: Quincey Morris <email@hidden>)

  • Prev by Date: Unnecessary Boolean Warning
  • Next by Date: Re: Unnecessary Boolean Warning
  • Previous by thread: Re: Multithreaded Coredata save in Lion
  • Next by thread: Unnecessary Boolean Warning
  • Index(es):
    • Date
    • Thread