O'Reilly logo

Mastering iOS 10 Programming by Donny Wals

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Reading data with a simple fetch request

The simplest way to fetch data from your database is to use a fetch request. The managed object context forward fetch requests to the persistent store coordinator. The persistent store coordinator will then forward the request to the persistent store, which will then convert the request to a SQLite query. Once the results are fetched, they are passed back up this chain and converted to NSManagedObjects. By default, these objects are faults. When an object is a fault, it means that the actual properties and values for the object are not fetched yet but they will be fetched once you begin accessing them. This can greatly reduce your app's memory usage.

Let's take a look at an example of a simple fetch request: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required