Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

MrFusion

macrumors 6502a
Original poster
Jun 8, 2005
613
0
West-Europe
Is there any uptodate guide, article, sample code on NSPersistentDocument?

I have multiple nsmanagedobject contexts and so I need to overwrite the read and write functions of NSPersistentDocument. Things have changed substantially in the last few years and it's not clear when steps have to be taken in the various functions.
Code:
func readFromURL(absoluteURL: NSURL, ofType typeName: FileType) throws
func writeToURL(absoluteURL: NSURL, ofType typeName: FileType, forSaveOperation saveOperation: NSSaveOperationType, originalContentsURL absoluteOriginalContentsURL: NSURL?) throws
func revertToContentsOfURL(url: NSURL, ofType typeName: String) throws
The revertToContentsOfURL is most puzzling. Are you supposed to remove and re-add the persistent store or just reset the context?

Can a file just be moved by cocoa without affecting the persistent store (SQLite) and coordinators? The document file is basically the persistent store file, so I am worried the database is going to get yanked out from under me.
 
Last edited by a moderator:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.