Note that there are some explanatory texts on larger screens.

plurals
  1. POUiManagedDocument works fine in simulator, but UIDocumentStateSavingError on iPhone
    primarykey
    data
    text
    <p>I use a uiManagedDocument singleton as suggested here: <a href="http://adevelopingstory.com/blog/2012/03/core-data-with-a-single-shared-uimanageddocument.html" rel="nofollow">http://adevelopingstory.com/blog/2012/03/core-data-with-a-single-shared-uimanageddocument.html</a></p> <p>the document is accessed by a fetchedResultsController and displayed in a tableViewController.</p> <pre><code>+ (DocumentHandler *)sharedDocumentHandler { static dispatch_once_t once; dispatch_once(&amp;once, ^{ _sharedInstance = [[self alloc] init]; }); return _sharedInstance; } - (id)init { self = [super init]; if (self) { NSURL *url = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]; url = [url URLByAppendingPathComponent:@"ElphiDB"]; self.document = [[UIManagedDocument alloc] initWithFileURL:url]; [self.logger log:@"DocumentHandler Initializing document"]; // Set our document up for automatic migrations NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption, [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil]; self.document.persistentStoreOptions = options; } return self; } - (void)performWithDocument:(OnDocumentReady)onDocumentReady { void (^OnDocumentDidLoad)(BOOL) = ^(BOOL success) { onDocumentReady(self.document); [self.logger log:[NSString stringWithFormat:@"performWithDocument success=%d",success]]; }; if (![[NSFileManager defaultManager] fileExistsAtPath:[self.document.fileURL path]]) { [self.document saveToURL:self.document.fileURL forSaveOperation:UIDocumentSaveForCreating completionHandler:OnDocumentDidLoad]; } else if (self.document.documentState == UIDocumentStateClosed) { [self.document openWithCompletionHandler:OnDocumentDidLoad]; NSLog(@"DocumentHandler performWithDocument Open:%@",[self.document description]); } else if (self.document.documentState == UIDocumentStateNormal) { OnDocumentDidLoad(YES); NSLog(@"DocumentHandler performWithDocument state normal"); } if (self.document.documentState != UIDocumentStateNormal) { [self.logger log:[NSString stringWithFormat: @"DocumentHandler problem-%@",[self.document description]]]; } </code></pre> <p>}</p> <p>//in tableViewController</p> <pre><code> - (void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; RootNavigationController *rootNC=(RootNavigationController*)self.navigationController; if (!self.plugDocument) { [[DocumentHandler sharedDocumentHandler] performWithDocument:^(UIManagedDocument *document) { [self.logger log:[NSString stringWithFormat:@"PlugsTVC VWA - call documentHandler doc=%@",document]]; self.plugDocument=document; self.plugFetcher.document=document; [self setupFetchedResultsController]; [self fetchPlugDataIntoDocument:document]; }]; }else{ [self.logger log:[NSString stringWithFormat:@"PlugsTVC VWA doc=%@ does exist",self.plugDocument]]; [self fetchPlugDataIntoDocument:self.plugDocument]; } } </code></pre> <p>The app works fine on the 6.0 simulator but on the device, the table is blank and the document shows a problem, either UIDocumentStateSavingError or UIDocumentStateEditingDisabled. I have no idea what could cause this to run differently on the phone vs. the simulator</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload