nspersistentdocument

Are NSPersistentDocument and UIManagedDocument compatible?

心已入冬 提交于 2020-05-13 07:13:50
问题 I would like to create a NSPersistentDocument in Mac OS X and read this document as a UIManagedDocument on iOS 7. Is this possible? Are both file formats compatible? Thank you! 回答1: Interesting question - I can confirm that the basic core data files are compatible. I have a Mac app and an iOS app using the same file that gets synced using iCloud. The app is a document based app and currently I have been storing the actual database file in iCloud so the whole file gets sync'ed by iCloud. This

Are NSPersistentDocument and UIManagedDocument compatible?

三世轮回 提交于 2020-05-13 07:13:05
问题 I would like to create a NSPersistentDocument in Mac OS X and read this document as a UIManagedDocument on iOS 7. Is this possible? Are both file formats compatible? Thank you! 回答1: Interesting question - I can confirm that the basic core data files are compatible. I have a Mac app and an iOS app using the same file that gets synced using iCloud. The app is a document based app and currently I have been storing the actual database file in iCloud so the whole file gets sync'ed by iCloud. This

NSDocument: The document could not be autosaved. The file has been changed by another application

时光总嘲笑我的痴心妄想 提交于 2020-02-03 05:04:42
问题 A search on the title of this post reveals that it's pretty common; indeed, I've gotten this error from Xcode. But I can't seem to find any fixes. I'm seeing it now when I run my program, and it appears to occur during or after changeCountTokenForSaveOperation is called. It seems related to the undo manager, rather than to the fact that i'm using core data, but I may be wrong. Does anyone know what causes this or how to fix it? 回答1: This error can occur with NSPersistentDocument when you

autosavesInPlace causes New Document save to fail

无人久伴 提交于 2020-01-17 08:43:21
问题 I have a NSPersistentDocument based app which fails to save a new document when autosavesInPlace is set to return YES , return NO and the problem disappears. I create a new document Make some changes Save it , thus running NSSaveAsOperation , the name of the document and the URL changes and all appears to be well but the next save will throw a very descriptive NSPersistentStoreSaveError = 134030, // unclassified save error - something we depend on returned an error This only happens when the

NSManagedObjectContextObjectsDidChangeNotification not always called instantly

a 夏天 提交于 2019-12-12 08:05:07
问题 I have an Mac Application using a NSPersistentDocument. I want to get notified when Objects are deleted to save this information using Core Data. So I'm listening for NSManagedObjectContextObjectsDidChangeNotification. Often it is called instantly when objects are deleted, but sometimes it is only called after the persistent document is saved with all deleted objects not being notified before. Because I want to let the user directly export all existing objects (and not the deleted anymore)

CoreData autosaving and not loading all data after autosave

安稳与你 提交于 2019-12-12 03:11:55
问题 I have an NSPersistentDocument subclass using NSManagedObject subclasses for my data. When a new document is opened, I do some initializing of data structures (trivial amount of populating fields). What I've noticed is that the Untitled document gets autosaved, and when the application re-opens, that document gets loaded. If the application quits, the user doesn't (by default) get prompted with the save dialog. If the window closes, the user does. First question: I want to call up the save

CoreData not setting type as XML

荒凉一梦 提交于 2019-12-11 07:12:25
问题 I'm having a hard time debugging a problem with my data (CoreData, NSPersistentDocument). I have a subclass of NSPersistentDocument. I am using NSManagedObject subclasses / standard Core Data models. I'm not doing anything special in NSPersistentDocument or with the NSManagedObject classes. I am merely creating an object (in NSPersistentDocument's subclass): [NSEntityDescription insertNewObjectForEntityForName:@"ModelName" inManagedObjectContext:[self managedObjectContext]]; When I attempt to

New project New Model NSPersistentDocument This NSPersistentStoreCoordinator has no persistent stores

▼魔方 西西 提交于 2019-12-11 05:45:54
问题 I have been searching stackoverflow and Googling for hours. I made a simple project to mess around with Core Data and bindings. It added an entity to the model and it wouldn't work any more. I was getting "This NSPersistentStoreCoordinator has no persistent stores It cannot perform a save operation" whenever I tried to add data to a new document. I followed every piece of advice I could find with no luck. Finally, I made a new project (NSPersistentDocument based) and I made a new model from

Is -makeWindowControllers the best place to initialize an NSPersistentDocument?

。_饼干妹妹 提交于 2019-12-06 14:51:36
问题 When loading an existing document using NSPersistentDocument , as part of initialization I'd like to prepare some content: NSFetchRequest *req = [NSFetchRequest fetchRequestWithEntityName:@"DocumentRoot"]; NSArray *results = [self.managedObjectContext executeFetchRequest:req error:NULL]; if (results.count) self._docRoot = [results objectAtIndex:0]; When I put this code in -init , the fetch request doesn't return any results. I encountered this problem while refactoring the view-controller

Is -makeWindowControllers the best place to initialize an NSPersistentDocument?

大憨熊 提交于 2019-12-04 20:35:06
When loading an existing document using NSPersistentDocument , as part of initialization I'd like to prepare some content: NSFetchRequest *req = [NSFetchRequest fetchRequestWithEntityName:@"DocumentRoot"]; NSArray *results = [self.managedObjectContext executeFetchRequest:req error:NULL]; if (results.count) self._docRoot = [results objectAtIndex:0]; When I put this code in -init , the fetch request doesn't return any results. I encountered this problem while refactoring the view-controller components from my NSPersistentDocument subclass to a new NSWindowController subclass. I used to handle