Adding Car Display Behaviors

Displaying object information is another common task. A UILabel displays the string from its text attribute in the interface, using whatever font, size, and color you specify. When the text attribute changes, the label updates.

You need four things to use UILabel for displaying changing information: a label, a connection to that label, a string to display, and code to set the label’s text.

You have already added the car information label to your scene. You have also created a connection, an IBOutlet, to that label. Adding a description for a car can be done in a few ways. One is by adding a public method. Another is using a read-only property and custom getter. Implement the property and getter by following these ...

Get Learning iOS Development: A Hands-on Guide to the Fundamentals of iOS Programming 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.