Fetch Request Templates

Determining the correct predicate format to use for every fetch can become laborious. Thankfully, the Xcode Data Model Designer supports predefining fetch requests. These reusable templates are easier to configure than predicates and reduce repeated code. Fetch request templates are configured using a series of drop-down boxes and fields specific to the application’s model. Unfortunately, given their simplicity they aren’t as powerful as predicates. If you need features such as custom AND/OR combinations, they’re missing and you’ll have to revert to predicate programming.

Update Grocery Dude as follows to create a fetch request template:

1. Select Model.xcdatamodeld.

2. Click Editor > Add Fetch Request.

3. Set the name ...

Get Learning Core Data for iOS: A Hands-On Guide to Building Core Data Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.