4 ms·
A lot of developers (myself included) don't use the dot syntax for property access for this reason and another: x.foo = z; becomes an ambiguous statement in ob
by nomurrcy 15y ago
A lot of developers (myself included) don't use the dot syntax for property access for this reason and another:
x.foo = z; becomes an ambiguous statement in obj-c when you use dot access. Is x an object? then this is a message send. Is x a struct? then this is an assignment.
Typically in my interface file, I explicitly define my member variables with a leading '_';
@interface Foo {
NSObject_bar;
}
@property(nonatomic, retain) NSObject bar;
@implementation Foo
@synthesize bar=_bar;
@end
And if I want to access bar I use [x bar], [x setBar:y]; it is easy to visually scan for direct use of member values by looking for the leading '_'