Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Overriding property accessor names in Objective-C with @synthesize

Tags:

objective-c

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.

like image 423
Coocoo4Cocoa Avatar asked Nov 30 '22 07:11

Coocoo4Cocoa


2 Answers

I think you just have it backwards in your @synthesize. What you want is:

@synthesize bar = foo;
like image 149
Kelan Avatar answered Dec 01 '22 20:12

Kelan


You can change the getter name when you declare the property (getter=bar).

like image 29
PEZ Avatar answered Dec 01 '22 20:12

PEZ