You should use @synthesize iVar = _iVar;
, but maybe soon you won't need to synthesize at all ;)
I would say that the options given by Xcode are just the code completion being a bit buggy.
Strictly speaking, the name you use doesn't matter at all (as long as there aren't any collisions), @synthesize iVar = i_va_R;
is perfectly legal, so is:
@synthesize foo = bar;
@synthesize bar = foo;
// DO NOT DO THIS IN REAL LIFE!!
All you are saying is that you want the property to be backed by an instance variable with the given name. If you never access the instance variable directly (always use self.iVar
rather than iVar
or _iVar
) then it doesn't really matter at all what you use, it only matters to the rest of the code if you want to access the iVar directly.
Just to clarify a little more, here is an example of of how the above could be implemented without using properties:
@interface MyBadClass {
int foo;
int bar;
}
- (int)foo;
- (void)setFoo:(int)foo;
- (int)bar;
- (void)setBar:(int)bar;
@end
@implementation MyBadClass
- (it)foo
{
return bar;
}
- (void)setFoo:(int)foo
{
bar = foo;
}
- (int)bar
{
return foo;
}
- (void)setBar:(int)bar
{
foo = bar;
}
@end
(PS: I am using int
s to avoid dealing with memory management, the same applies to objects too though)