Effective Objective-C 2.0

{% img right /assets/images/2014/EffectiveObjectiveC.jpeg %} I purchased this book last June so it is long overdue that I posted a review. The full title is Effective Objective-C 2.0: 52 Specific Ways to Improve Your iOS and OS X Programs. by Matt Galloway (Published May 20, 2013 by Addison-Wesley Professional).

First Impressions

This is not a beginners guide to Objective-C or iOS programming. It assumes you have some knowledge of the language already and are looking to develop a deeper understanding. As Matt himself writes in the preface:

It is not the aim of this book to teach the basics of Objective-C, which you can learn from many other books and resources. Instead, this book teaches how to use the language effectively.

The book is divided into seven chapters covering different aspects of the language. Each chapter contains between 5 and 10 separate articles addressing specific topics. Each article finishes with a summary of the key points to remember. You can read it in order but the structure of the book makes it work really well as a reference to dip into when you need a refresh on a topic.

In Depth

A quick tour of the topics covered will give you a feel for the book:

Chapter 1: Accustoming Yourself to Objective-C This chapter covers some basic language features that everybody using Objective-C should become familiar with. What I like even with these more introductory topics is that Matt does not just provide the syntax of a feature but explains why you should prefer certain language features.

Chapter 2: Objects, Messaging, and the Runtime This chapter starts off gently with articles reviewing the use of Objective-C properties and object equality but before you start to think this a book for beginners it progresses on to discussions of class clusters, associated objects, method forwarding and method swizzling.

Chapter 3: Interface and API Design This chapter covers some common conventions and best practises for naming classes, methods and variables which make your code easier to reuse. For example using a three-letter prefix to avoid namespace clashes and why you should prefer immutable objects.

Chapter 4: Protocols and categories This chapter is in some ways a continuation of the previous one on interfaces discussing the implementation of the delegate pattern with protocols and using categories.

Chapter 5: Memory Management This first covers manual reference counting before introducing ARC, retain cycles and zombies. If you were ever tempted it also explains why you do not want to use retainCount - not that you can anymore, but the explanation is still useful.

Chapter 6: Blocks and Grand Central Dispatch Blocks and block syntax are powerful but often difficult to grasp. The explanation of blocks and the common pitfall of creating retain cycles by capturing self (or other objects) are worth reading over and over again if you struggle with blocks. The items on dispatch queues and GCD also include when to use the often overlooked NSOperationQueue.

Chapter 7: The System Frameworks A mix of framework related topics such as using block enumerations, the tricky topic of memory management when using Core Foundation classes via toll-free bridging, NSCache and NSSTimer.

In Summary

As I was writing this review I found my self getting sucked back into reading many of the articles which I think is a tribute to the quality of the writing. If you are relatively new to Objective-C there is a lot here that will help you master the finer details of the language.

If you are a long time Objective-C developer you may feel you already know everything there is to know about memory management or protocols or the system frameworks. You may even disagree with some of the preferences (every Objective-C developer has a different opinion on when to directly access ivars). However given how complex some of these topics are I would be surprised if you didn’t learn something.

Either way if you have any interest in Objective-C I can recommend adding it to your bookshelf.

Never miss a post!

iOS Size Classes Cheat Sheet

Subscribe and get my free iOS Size Classes Cheat Sheet

Unsubscribe at any time.
No time to watch WWDC videos?

Sign up to get my iOS posts direct to your inbox and I will send you a free PDF of my iOS Size Classes Cheat Sheet.

Unsubscribe at any time.
Archives Categories
comments powered by Disqus