Declaring Properties

Properties are declared in the interface for a class. They can be declared in the header (.h) file for external visibility, or in the implementation file (.m) for properties that should be visible only to the instance. Before properties were available, instance variables were declared like so:

@interface ICFViewController : UIViewController{IBOutlet UITextView *myTextView;IBOutlet UILabel *myLabel;UIImage *attachmentImage;UIImagePickerController *picker;}

In the implementation file, accessor methods needed to be written for each instance variable. This code is tedious and repetitive to write, and simple errors in accessor methods can have dire memory management consequences like leaks or crashes. ...

Get iOS Components and Frameworks: Understanding the Advanced Features of the iOS SDK 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.