Pro Core Data for iOS: Data Access and Persistence Engine for iPhone, iPad, and iPod touch Second Edition by Michael Privat Robert Warner
Author:Michael Privat, Robert Warner
Language: eng
Format: epub
Publisher: Apress®
Published: 2011-11-20T16:00:00+00:00
Building the Test Application
You can get data out of a Core Data persistent store in two ways. If you already have handles to existing managed objects, then you can follow the object graph and relationships to pull more objects out. If you don't have any objects yet, such as when the application first starts, then you must go get them directly out of the persistent store. In this case, you typically use an instance of NSFetchRequest to go get objects. You initialize an NSFetchRequest with an NSEntityDescription, which helps narrow the result set by constraining the type of managed objects to retrieve. This chapter shows you how to narrow your fetch requests in various ways using the NSFetchRequest class.
To support the examples in this chapter, you'll reuse the OrgChart application from Chapter 2. We suggest you make a copy of the application because you will make some changes to Chapter 2's data model in this chapter. Since Chapter 2, you've learned that Core Data can better deal with managing the object graph if all the relationships have an inverse, so go back to the OrgChart application and add reverse relationships for leader and employees. To accomplish this, open the OrgChart.xcdatamodeld data model, and select the Person entity. Since Organization already has the leader relationship to the Person entity, add a relationship called organization in Person, set the destination to Organization, and select leader as the inverse relationship. Person also has a self-referencing relationship called employees, so create a relationship from Person to Person, call it manager, and select employees as the inverse relationship. Also, rename the id attribute of Person to age. Your Person entity should look like Figure 6–1.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Deep Learning with Python by François Chollet(16098)
The Mikado Method by Ola Ellnestam Daniel Brolund(13375)
Hello! Python by Anthony Briggs(13181)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(12341)
Dependency Injection in .NET by Mark Seemann(12198)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(10955)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(10804)
A Developer's Guide to Building Resilient Cloud Applications with Azure by Hamida Rebai Trabelsi(10540)
Grails in Action by Glen Smith Peter Ledbrook(10264)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(10201)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(9552)
Hit Refresh by Satya Nadella(9040)
Kotlin in Action by Dmitry Jemerov(8930)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(8681)
The Kubernetes Operator Framework Book by Michael Dame(8488)
Exploring Deepfakes by Bryan Lyon and Matt Tora(8308)
Robo-Advisor with Python by Aki Ranin(8261)
Practical Computer Architecture with Python and ARM by Alan Clements(8234)
Implementing Enterprise Observability for Success by Manisha Agrawal and Karun Krishnannair(8203)