Theocacao
Leopard
Design Element
Comment on "More Than Anything, Leopard is Wish Fulfillment"
by Scott Stevenson — Oct 27
@Simon Robins: Why is NSString *location written twice?
Why isn't the property written as: @property location?


A property doesn't necessarily have to be backed by an instance variable with the same name, or an instance variable at all.

@interface Person : NSObject { NSString *realLocation; NSString *fakeLocation; } @property NSString *location1; @property NSString *location2; @end @implementation Person @synthesize location1=realLocation; @synthesize location2=fakeLocation; @end

Here, both properties are declared as NSString. By default, the property uses an instance variable of the same name, but you can override it with the equals sign. The @sythesize directive reads the information from the @property directive to determine the type is NSString.
Back to "More Than Anything, Leopard is Wish Fulfillment"
Design Element

Copyright © Scott Stevenson 2004-2015