fuzzygoat
fuzzygoat

Reputation: 26223

declare @property with different name?

I was just working through a iPhone book and I noticed a comment that stated...

If you declare a property with a different name than its underlying instance varaible (which can be done with the @synthesize directive)

Can anyone explain how the above quote might work, I am just curious as all references to @property / @synthesize always look like my code below.

@interface Planet : NSObject {
    NSString *planetName;
}

@property(copy) NSString *planetName;
...
@synthesize planetName;

gary

Upvotes: 1

Views: 285

Answers (1)

Chuck
Chuck

Reputation: 237030

I would presume the book would go on to explain, but i would look like this:

@interface Planet : NSObject {
    NSString *name;
}

@property(copy) NSString *planetName;
...
@synthesize planetName = name;

Upvotes: 3

Related Questions