I am very new to CoreData and to my iPhone app. I want to know how to save some text and then load it back. But the trick is to load it back when the date in UIDatePicker is the same as when I saved it as a calendar.
I hope you can help. Its quite important, I will learn how to do it pretty soon, so any help received a lot of thanks, thanks.
UPDATE: Thanks for the answers, especially for the sample code. However, I have some problems that understand how this fits together, forgive me. I want to know how this works, but getting it to work on average will be really helpful.
I understand some of these errors, only correcting them in the correct manner is my problem. Hope you can help.
Presumably, I put your first code snippet in the finished editing method (saving when you exit the text field), and then the second piece in the method with the modified date (loading when the date changes)?
Does this code use object and property names? How exactly do I need to configure the xcdatamodel file? Do I need to use this code, or does it just show which objects and properties I need?
DatedText{ savedText:String dateSaved:Date }
This line says that "mo" is not declared: (FIXED)
newDatedText=mo=[NSEntityDescription insertNewObjectForEntityForName:@"DateText" inManagedObjectContext:theManagedObjectContext];
Allegedly below is "someText" is the text I want to save? Is 'aDateObject' the date of my UIDatePicker?
[newDatedText setValue:someText forKey:@"savedText"]; [newDatedText setValue:aDateObject forKey:@"dateSaved"];
The query for the 'moc' member 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];
The request of the 'moc' member in what is not a structure or union:
NSArray *fetchedObjs=[self.moc executeFetchRequest:theFetch error:&fetchError];