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.
Hope you can help in anyway. Its pretty important I learn how to do this fairly soon, so any help is massively appreciated, thanks.
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.
I understand some many of these errors, only fixing them in the correct manner is my issue. Hope you can help.
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)?
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?
DatedText{
savedText:String
dateSaved:Date
}
This line says 'mo' is undeclared: (FIXED)
newDatedText=mo=[NSEntityDescription insertNewObjectForEntityForName:@"DateText"
inManagedObjectContext:theManagedObjectContext];
Presumably below 'someText' is the text I want save? And the 'aDateObject' is the date in my UIDatePicker?
[newDatedText setValue:someText forKey:@"savedText"];
[newDatedText setValue:aDateObject forKey:@"dateSaved"];
Request for member 'moc' in something not a structure or union:
NSEntityDescription *testEntity=[NSEntityDescription entityForName:@"DatedText" inManagedObjectContext:self.moc];
Whats 'targetDate' (undeclared)? UIDatePicker date again?
NSPredicate *pred=[NSPredicate predicateWithFormat:@"dateSaved==%@", targetDate];
Request for member 'moc' in something thats not a structure or a union:
NSArray *fetchedObjs=[self.moc executeFetchRequest:theFetch error:&fetchError];