Class Extensions

Now let’s return to the circleColor property that you declared in a class extension for BNRHypnosisView. What is the difference between a property declared in a class extension and one declared in a header file? Visibility.

A class’s header file is visible to other classes. That, in fact, is its purpose. A class declares properties and methods in its header file to advertise to other classes how they can interact with the class or its instances.

Not every property or method is for public consumption, however. Properties and methods that are used internally by the class belong in a class extension. The circleColor property is only used by the BNRHypnosisView class. No other class needs to know about this property. ...

Get iOS Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.