Join Simon Allardice for an in-depth discussion in this video Creating custom managed object subclasses, part of Core Data for iOS and OS X.
So I'm continuing to use this straightforward example that I have where this Cocoa project…has a Course entity with author, releaseDate, and title, and then in my code I've got a method…that instantiates a managed object based on that entity, seta its properties, and saves it.…But I promised there was a better way to do this, and that's by creating a custom class…for this managed object instead of using the generic NSManagedObject pointer.…Now these doesn't mean that for the same idea we need two things, an entity called course…in our data model, and also a custom Objective-C class also called course.…
The names don't have to match, but they usually would.…The entity is for Core Data to describe how this managed object is going to be saved, and…the custom class will be for our app to describe our custom behavior for this managed object.…And it's very, very common to have both an entity and a matching custom class.…Now if you're wondering do I need to create custom classes?…No, you don't need to.…If you have an entity that is just a data structure, you don't need a custom class for it.…
- 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.<br /><br />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:<br /><br />[self dismissModalViewControllerAnimated:YES];<br /><br />to the current recommended version:<br /><br />[self dismissViewControllerAnimated:YES completion:nil];<br /><br />It should take care of that message.