Database Reference
In-Depth Information
For the purposes of this app, you don't care about the content of each individual
sale—for example, the date of the sale or the name of the purchaser—just how
many there are.
Measure the problem
You'll use XCTest again to measure the performance of the employee detail screen.
Open EmployeeDetailViewController.swift and find
salesCountForEmployee(employee:) .
public func salesCountForEmployee(employee: Employee ) -> String {
let fetchRequest = NSFetchRequest (entityName: "Sale" )
let predicate =
NSPredicate (format: "employee == %@" , employee)
fetchRequest. predicate = predicate
var error : NSError ?
let context = employee. managedObjectContext
let results =
context. executeFetchRequest (fetchRequest, error: &error)
if results == nil {
println ( "Error: \(error?. localizedDescription ) " )
return "0"
}
return " \(results. count ) "
}
 
Search WWH ::




Custom Search