Note that there are some explanatory texts on larger screens.

plurals
  1. PODatePicker Stopping CoreData Work
    primarykey
    data
    text
    <p>I have an app which saves text and the date from a UIDatePicker and then shows that note if you got back into that date in the UIDatePicker.</p> <p>Its works great! Only I have found that setting the UIDatePicker date to today stops CoreData working!</p> <p>Its only when I run this setDate line does it stop core data from working. The app runs fine without crashing, it just doesn't save any data. If I comment that line out, its works a charm. But I need to have the UIDatePicker on today when the app loads.</p> <p>I use this when the application starts:</p> <pre><code>NSDate *now = [[NSDate alloc] init]; [datePicker setDate:now]; </code></pre> <p>This to fetch the note:</p> <pre><code>NSFetchRequest *fetch = [[NSFetchRequest alloc] init]; NSEntityDescription *testEntity = [NSEntityDescription entityForName:@"DatedText" inManagedObjectContext:self.managedObjectContext]; [fetch setEntity:testEntity]; NSPredicate *pred = [NSPredicate predicateWithFormat:@"dateSaved == %@", datePicker.date]; [fetch setPredicate:pred]; NSError *fetchError = nil; NSArray *fetchedObjs = [self.managedObjectContext executeFetchRequest:fetch error:&amp;fetchError]; if (fetchError != nil) { NSLog(@"fetchError = %@, details = %@",fetchError,fetchError.userInfo); } noteTextView.text = [[fetchedObjs objectAtIndex:0] valueForKey:@"savedText"]; </code></pre> <p>And this to save the note:</p> <pre><code>NSManagedObject *newDatedText; newDatedText = [NSEntityDescription insertNewObjectForEntityForName:@"DatedText" inManagedObjectContext:self.managedObjectContext]; [newDatedText setValue:noteTextView.text forKey:@"savedText"]; [newDatedText setValue:datePicker.date forKey:@"dateSaved"]; NSError *saveError = nil; [self.managedObjectContext save:&amp;saveError]; if (saveError != nil) { NSLog(@"[%@ saveContext] Error saving context: Error = %@, details = %@",[self class], saveError,saveError.userInfo); } </code></pre>
    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.
 

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