O'Reilly logo

Cocoa Design Patterns by Donald A. Yacktman, Erik M. Buck

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

7. Anonymous Type and Heterogeneous Containers

Objective-C defines the type id, which is known as the Anonymous Type. The id type tells the compiler that a variable points to an object but doesn’t give the compiler any more specific information about the kind of object, hence the object is anonymous. Objective-C programmers quickly become familiar with the pervasive use of the Anonymous Type and forget that this feature is seldom encountered in other languages. Objective-C’s Anonymous Type and Cocoa’s Heterogeneous Containers deserve special recognition as patterns in their own right and facilitators for other patterns.

Motivation

Use the Anonymous Type pattern to send messages to anonymous objects, including objects that are not available ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required