Note that there are some explanatory texts on larger screens.

plurals
  1. POSave and Load Data - CoreData
    primarykey
    data
    text
    <p>I am very new to CoreData and in my iPhone app I want to know how to save some text, then load it back in. But the trick is, loading it back in when the date in the UIDatePicker is the same as when I saved it, like a calendar.</p> <p>Hope you can help in anyway. Its pretty important I learn how to do this fairly soon, so any help is massively appreciated, thanks.</p> <p>UPDATE: Thanks for the replies, especially the for the code sample. However I have some issues understand how this fits together, forgive me. I want to learn how this works, but to get it working in the mean time will really be helpful.</p> <p>I understand some many of these errors, only fixing them in the correct manner is my issue. Hope you can help.</p> <p>Presumably I put your first code chunk in the did finish editing method (save when leaving text box) and then the second chunk in the date changed method (load when changing the date)?</p> <p>This code, does this use the entity and property names? How exactly do I need to setup my xcdatamodel file? Do I need to use this code or does this just demonstrate what entities and properties I need?</p> <pre><code>DatedText{ savedText:String dateSaved:Date } </code></pre> <p>This line says 'mo' is undeclared: (FIXED)</p> <pre><code> newDatedText=mo=[NSEntityDescription insertNewObjectForEntityForName:@"DateText" inManagedObjectContext:theManagedObjectContext]; </code></pre> <p>Presumably below 'someText' is the text I want save? And the 'aDateObject' is the date in my UIDatePicker?</p> <pre><code>[newDatedText setValue:someText forKey:@"savedText"]; [newDatedText setValue:aDateObject forKey:@"dateSaved"]; </code></pre> <p>Request for member 'moc' in something not a structure or union:</p> <pre><code>NSEntityDescription *testEntity=[NSEntityDescription entityForName:@"DatedText" inManagedObjectContext:self.moc]; </code></pre> <p>Whats 'targetDate' (undeclared)? UIDatePicker date again?</p> <pre><code>NSPredicate *pred=[NSPredicate predicateWithFormat:@"dateSaved==%@", targetDate]; </code></pre> <p>Request for member 'moc' in something thats not a structure or a union:</p> <pre><code>NSArray *fetchedObjs=[self.moc executeFetchRequest:theFetch error:&amp;fetchError]; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    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