For good encapsulation, decent Objective-C
programmers put their private
ivars in a private extension
declared in the main implementation file, like this:
// MyClass.m
@interface MyClass () {
float value;
}
@end
@implementation MyClass
@end
But recently, I found a simpler way to hide private
ivars: ivars can be declared in a {}
block following @implementation
, like this:
// MyClass.m
@implementation MyClass {
float value;
}
@end
It is really handy when no private methods but only private
ivars need to be hidden.
However, I'm not sure about its syntax validity. Can anyone validate or invalidate it with some canonical references?