Questions tagged [uimanageddocument]

UIManagedDocument is a concrete subclass of UIDocument that integrates with Core Data. When you initialize a managed document, you specify the URL for the document location. The document object then creates a Core Data stack to use to access the document’s persistent store using a managed object model from the application’s main bundle.

The persistent store coordinator is set up automatically for you and you can configure it using it's persistentStoreOptions property. -you can use it as a data container, not just for documents. -you can listen to state and store content changes, which makes iCloud syncing easier

Read Apples documentation or an article by Erica Sadun. There is also a great demo video from Stanford Universities Paul Hegarty - check the Core Data demo on iTunes U.

188 questions
1
vote
2 answers

Why is UIManagedDocument so slow?

Here is a snippet of relevant code: NSURL *url = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]; url = [url URLByAppendingPathComponent:@"Demo Document"]; UIManagedDocument…
Nathan H
  • 48,033
  • 60
  • 165
  • 247
1
vote
1 answer

iOS UIManagedDocument closing

Unless done explicitly, is the only time a UIManagedDocument closed when the app is "quit"? By quit I mean when the user double taps the home button and holds onto the apps and closes them out. I ask because right now I have my app in a…
user1529956
  • 735
  • 2
  • 10
  • 24
1
vote
2 answers

Objective-C fetch doesn't always return a result

I have the following code: -(void) readAllQuestions { NSLog(@"Reading questions from database"); NSManagedObjectContext* moc = self.questionsDocument.managedObjectContext; moc.mergePolicy = NSRollbackMergePolicy; NSFetchRequest*…
1
vote
1 answer

UIManagedDocument, background thread and parent context

It is briefly mentioned in UIManagedDocument's documentation that To support asynchronous data writing, Core Data actually uses a pair of nested managed object contexts. Is that specific to UIManagedDocument or Core Data always does that? The…
Joe Shmo
  • 303
  • 5
  • 9
1
vote
1 answer

iOS application with local and iCloud support

If the ubiquity container (iCloud folder) is not available for whatever reason, I add any new documents to the users 'Documents' directory, however, should it become available again I add the documents to the ubiquity container. My question is, what…
Adam Carter
  • 4,741
  • 5
  • 42
  • 103
1
vote
0 answers

NSManagedObject attributes are reset to nil

I am creating an NSManagedObject subclass (Group), set some properties/attributes and then pass it on to a different object (where it is stored in a strong property). This object takes some of the Group information and sends it to a server over an…
Scott Berrevoets
  • 16,921
  • 6
  • 59
  • 80
1
vote
3 answers

NSPersistentStoreCoordinator not created on a UIManagedDocument

I'm starting to learn about UIManagedDocument and its abilities. From what I understand of it its a form of database stored in a location in the documents directory. Anyway, I'm trying to use it as a database, by storing data within its…
Adam Carter
  • 4,741
  • 5
  • 42
  • 103
1
vote
1 answer

Opening UIManagedDocument on Simulator takes a long time

Im looking for a quick fix to my problems with the iPhone Simulator. The code I use to access my database is: + (NSURL*) databaseURL { if(!databaseURL){ databaseURL = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory…
BYZZav
  • 1,418
  • 1
  • 19
  • 35
1
vote
2 answers

Prevent UIDocument openWithCompletionHandler being called when already opening

I have a singleton class (DTTSingleton) with the following methods: + (UIManagedDocument *)managedDocument { static UIManagedDocument *managedDocument = nil; static dispatch_once_t mngddoc; dispatch_once(&mngddoc, ^ { …
Darthtong
  • 1,017
  • 4
  • 18
  • 30
1
vote
0 answers

UIDocumentStateSavingError in SaveToURL

I am trying to save coredata file with some changes (locally, not through iCloud) but the "saveToURL" method completion handler is not invoked. With the debugger I saw that the file is in state UIDocumentStateSavingError. I haven't seen any…
1
vote
0 answers

UIManagedDocument and "This NSPersistentStoreCoordinator has no persistent stores" Error

I'm trying to use a UIManagedDocument to set up my core data stack in an application i am building. I've got an object DocumentController that has this in the init method: - (id)init { if (self = [super init]) { //custom initialization …
Sean Danzeiser
  • 9,141
  • 12
  • 52
  • 90
1
vote
1 answer

Save/Load system for game using CoreData

I've been trying to build a simple load/save system for a game using Core Data. Saving, loading and creating my UIManagedDocument works fine. Setting and loading values for attributes in my savegame entity works fine as well. The problem is that…
benfranke
  • 84
  • 4
1
vote
2 answers

Parsing in an NSManagedObjectContext background thread and issues with "different contexts"

I am trying to parse a XML document and store its data in a Core Data store using an background queue. I am using the new nested UIManagedObjectContext concept introduced in iOS 5. I have added a new category to my NSManagedObject company, which…
AlexR
  • 5,514
  • 9
  • 75
  • 130
1
vote
1 answer

Getting the URL of a UIManagedDocument

Currently, I determine the documents directory and retrieve the URLs within, saving to an array property: // Returns an array of all the Vacations on file. - (void)findVacationsOnFile { self.vacationURLs = [[NSArray alloc] init]; //…
Michael Mangold
  • 1,741
  • 3
  • 18
  • 32
1
vote
2 answers

Creating a UIManagedDocument and the initial iCloud sync

I'm adding iCloud syncing to my app. My UIManagedDocument store is in the sandbox, and its change log is in iCloud (specified by NSPersistentStoreUbiquitousContentURLKey). The problem is that when I install and run the app for the 1st time on a 2nd…
TotoroTotoro
  • 17,524
  • 4
  • 45
  • 76