Reputation: 50826
I'm trying to find documentation on how I can override a property name in Objective-C with @synthesize. If I have an instance variable name of 'foo', I want to write it's accessor as 'bar'.
Doing something such as
@synthesize foo = bar;
gives a compile-time error.
Upvotes: 4
Views: 3562
Reputation: 2276
I think you just have it backwards in your @synthesize. What you want is:
@synthesize bar = foo;
Upvotes: 13
Reputation: 17004
You can change the getter name when you declare the property (getter=bar).
Upvotes: 6
Reputation: 15011
You can but "bar" has to exist first (be a declared variable). From the documentation
You can use the form property=ivar to indicate that a particular instance variable should be used for the property, for example:
@synthesize firstName, lastName, age = yearsOld;
Upvotes: 3