Accessing Properties

If properties have been declared in the header file, they can then be accessed from other classes:

NSString *setString = @"Some string...";ICFObject *anObject = [[ICFObject alloc] init];[anObject setMyString:setString];UIImage *anImage = [anObject myImage];[anObject release];

The getter method for a property is simply the name of the property. The setter method for the property is “set” prefixed to the name of the property, in camel case. In the previous code example, the string property myString can be set using the method setMyString:.

To access a property internally, the keyword self can be used:

[self setMyString:@"A new string"];UIImage *image = [self myImage ...

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.