Skip to Content
iOS 7 Programming Fundamentals
book

iOS 7 Programming Fundamentals

by Matt Neuburg
October 2013
Beginner content levelBeginner
422 pages
12h 35m
English
O'Reilly Media, Inc.
Content preview from iOS 7 Programming Fundamentals

Chapter 10. Cocoa Classes

Using the Cocoa Touch frameworks requires an understanding of how those frameworks organize their classes. Cocoa class organization depends upon certain Objective-C language features that are introduced in this chapter. The chapter also surveys some commonly used Cocoa utility classes, along with a discussion of the Cocoa root class.

Subclassing

Cocoa effectively hands you a large repertory of objects that already know how to behave in certain desirable ways. A UIButton, for example, knows how to draw itself and how to respond when the user taps it; a UITextField knows how to display editable text, how to summon the keyboard, and how to accept keyboard input.

Often, the default behavior or appearance of an object supplied by Cocoa won’t be quite what you’re after, and you’ll want to customize it. This does not necessarily mean that you need to subclass! Cocoa classes are heavily endowed with methods that you can call, and properties that you can set, precisely in order to customize an instance, and these will be your first resort. Always study the documentation for a Cocoa class to see whether instances can already be made to do what you want. For example, the class documentation for UIButton shows that you can set a button’s title, title color, internal image, background image, and many other features and behaviors, without subclassing.

Nevertheless, sometimes setting properties and calling methods won’t suffice to customize an instance the way you want to. ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

iOS 7 Programming Cookbook

iOS 7 Programming Cookbook

Vandad Nahavandipoor
Programming iOS 11

Programming iOS 11

Matt Neuburg
Programming iOS 12

Programming iOS 12

Matt Neuburg

Publisher Resources

ISBN: 9781491946039Errata PageSupplemental Content