Database Reference
In-Depth Information
Team : This class represents a country's team. It is an NSManagedObject subclass
with properties for each of its four attributes: teamName , qualifyingZone ,
imageName and wins . If you're curious about its entity definition, head over to
WorldCup.xcdatamodel .
Images.xcassets : The sample project's asset catalog contains a flag image for
every country in seed.json .
The first three chapters of this topic covered the Core Data concepts mentioned
above. If “managed object subclass” doesn't ring a bell or if you're unsure what a
Core Data stack is supposed to do, you may want to go back and reread the
relevant chapters. NSFetchedResultsController will be here when you return. :]
Otherwise, if you're ready to proceed, let's begin implementing the World Cup
application. You probably already know who won the World Cup last time, but this
is your chance to rewrite history for the country of your choice, with just a few
taps!
It all begins with a fetch request...
At its core, NSFetchedResultsController is a wrapper around the results of an
NSFetchRequest . Right now, the sample project contains static information. You're
going to create a fetched results controller to display the list of teams from Core
Data in the table view.
Go to ViewController.swift and import the Core Data framework:
import CoreData
Then, add a property to hold your fetched results controller:
var fetchedResultsController : NSFetchedResultsController !
Add the following code to the end of viewDidLoad to set up your fetched results
controller property:
//1
let fetchRequest = NSFetchRequest (entityName: "Team" )
//2
fetchedResultsController =
NSFetchedResultsController (fetchRequest: fetchRequest,
managedObjectContext: coreDataStack . context ,
sectionNameKeyPath: nil ,
cacheName: nil )
//3
 
Search WWH ::




Custom Search