Join Simon Allardice for an in-depth discussion in this video Creating and using a fetch request, part of Core Data for iOS and OS X.
We've see how to model some entities, we've seen how to create managed objects, placing…them in a managed object context and using that to save them.…But being able to create and save objects isn't much use if you can't get them back.…So let's see the third essential piece of the puzzle, how to retrieve--or as we say in…Core Data--how to fetch our objects.…Now everything we do will still revolve around the managed object context, the beating heart of Core Data.…But to fetch you must create a fetch request object.…
The fetch request describes what you want.…You don't fetch everything, and it's most basic a fetch request will say that you're…fetching all the objects of a particular entity.…Fetch all courses or fetch all books or fetch all publishers.…Now you can get more specific ordering or sorting the results, so fetch all books sorted…in order of publication date or only fetch specific things.…Just fetch all books with the word apple in the title, but you'll always need the entity.…And to create a fetch request, you really only need two things, the name of the entity, and…
- Understanding Core Data and object persistence frameworks
- Creating a Core Data project
- Exploring data modeling
- Creating entities, attributes, and relationships
- Creating managed objects
- Fetching in Core Data
- Implementing undo and redo support
- Creating a Core Data Cocoa app without code
- Responding to validation issues
- Converting store types
- Preloading default data
Skill Level Intermediate
Q: In the CoursesViewController.m file, I receive a message that the method dismissModalViewControllerAnimated is no longer supported by Apple. Is there a newer method to use?
A: You may have received the warning that a call to the dismissModalViewControllerAnimated: method is now deprecated.
This is a recently deprecated method, so the code _will_ continue to work using that call, but to remove the warning, change the code from:
to the current recommended version:
[self dismissViewControllerAnimated:YES completion:nil];
It should take care of that message.