Pro Core Data for iOS

I recently read Pro Core Data for iOS: Data Access and Persistence Engine for iPhone, iPad, and iPod Touch Apps (Books for Professionals by Professionals)
from Apress. The book is co-authored by Michael Privat and Rob Warner. Unsurprisingly the book is about Apple’s Core Data framework, specifically the iOS flavour. The book’s introduction includes the following statement:

Introductory texts give you introductory-level understanding of the Core Data framework, which is fine for introductory-level applications but not for applications that cross the chasm from toys to real-life.

This is why I was eager to read this book, due to most tutorials, articles and books providing an introductory-level understanding of Core Data. However, I was keen to explore recommended best practices, common architectures being used, and all the sticky anti-patterns that the unaware engineer may fall into.

The book is organised into nine chapters. The first six chapters primarily deal with what Core Data is and how it’s leveraged in an iOS application. The final three chapters delve into performance, migrations, and various advanced use cases of Core Data.

Whilst the book’s title is prefixed with “Pro”, the first six chapters provide all the detail a beginner requires to integrate Core Data into an app. The reader is taken through the creation of sample apps to aid understanding. These chapters provide good depth, detail and understanding. For example, Chapter One includes a section titled “History of Persistence in iOS.” Chapter Three includes details on creating custom persistent stores, including a thorough example.

Personally, Chapter Six “Refining Result Sets” was the highlight of the book. The authors guide the reader through using NSPredicate object graphs and its query language in order to filter results. This chapter is a complete guide for filtering and sorting, including sections on subqueries, aggregation, compound predicates, and multiple criterion sorting.

Chapter Seven is titled “Tuning Performance and Memory Usage.” The authors share some techniques they use to test and tune performance of real Core Data applications. This chapter includes an excellent section on memory usage and management. This is one area that is easy to forget as a beginner and one that more experienced developers should revise.

Chapter Nine was the most interesting chapter. Topics such as encryption, data change notifications, data seeding, and error handling are discussed.

So what’s the verdict? I found the book to be well written and thorough. My main issue was that the topics covered were still too basic for what I require. Ultimately, I wanted the book to be an extended version of chapters seven and nine. Unfortunately, things like third party tooling, such as the excellent mogenerator were not discussed. The error handling strategy discussed did not suggest a method of recovery, such as maintaining last known good backups or being able to automatically restore to a clean state. There was also no detailed discussion of architectures and common patterns, such as should Managed Object Contexts being explicitly passed or created or encapsulated in singletons for client code. When would each work and when wouldn’t it? Also multi-threaded applications and how to implement Core Data within them were not discussed.

In conclusion, the book is excellent for someone just starting their Core Data journey and requiring deeper understanding of Core Data’s usage. However, for the more advanced engineer, much of what is covered may already be known.

Disclaimer: I was given a free copy for review.