English |  Español |  Français |  Italiano |  Português |  Русский |  Shqip

Intermediate iOS Development

Patterns

The “Patterns” section of Beginning iOS Development: A Safari Guide introduced several key patterns, but there are many more. Erik Buck and Donald Yacktman’sCocoa Design Patterns provides thorough descriptions of the major design patterns used with Cocoa. Because the implementation of these patterns is within Objective-C and the Foundation framework, they are available to iOS.

The authors divide the book into five parts. The Beginning iOS Development: A Safari Tutorial covered the first part, and the fifth applies more to Cocoa than to iOS programming and so will be ignored. That leaves the fundamental patterns, decoupling patterns, and patterns that hide complexity. Ideally, you would read all the patterns; however, given the importance of the Objective-C runtime to iOS, the list of recommended patterns has been narrowed down to those that have some bearing on the runtime. This reduces the number of patterns while ideally adding to your understanding and appreciation of the runtime.

The fundamental patterns rely heavily on the Objective-C runtime, so almost all the patterns in that part of the book are included.

  • Cocoa Design Patterns, by Erik M. Buck and Donald A. Yacktman, Addison-Wesley Professional
    • Chapter 5, “Dynamic Creation
    • Chapter 6, “Category”
    • Chapter 7, “Anonymous Type and Heterogeneous Containers”
    • Chapter 9, “Perform Selector and Delayed Perform”
    • Chapter 10, “Accessors”
    • Chapter 11, “Archiving and Unarchiving”
    • Chapter 12, “Copying”

[02:15]

Decoupling patterns rely less heavily on the runtime. Consequently, fewer patterns are listed here than for the fundamental patterns.

[01:00]

The final part, patterns that hide complexity, has the fewest patterns of interest, but they are some of the most important.

  • Cocoa Design Patterns, by Eric M. Buck and Donald A. Yacktman
    • Chapter 25, “Class Clusters”
    • Chapter 27, “Proxies and Forwarding”

[01:00]

Of course, Apple does not have a monopoly on design patterns; you are free to make use of them in your own code. What patterns you use largely depends on what you’re trying to accomplish in your application, and to some degree on your personal preferences and comfort level. Rather than assign particular patterns to use, this section ends with a recommendation that you peruse the table of contents of Carlo Chung’s Pro Objective-C Design Patterns for iOS if you’re a patterns fan and you want to see how you might implement them in your code. The book is very much in the model of the Gang of Four.

Finally, before ending this section, there is one pattern you should always strive to implement.

[00:10]

There has been error in communication with Booktype server. Not sure right now where is the problem.

You should refresh this page.