Is following code, a good programming practice in objective-C ?
#import "Custom.h"
@interface Custom ()
@property (nonatomic, retain) UILabel *label;
@end
@implementation Custom
@synthesize label;
- (void) dealloc {
[label release];
[super dealloc];
}
@end
The idea behind this is that all properties you declare in your header file, are visible and accesible for everyone outside that class.
To respect the encapsulation principle of OOP, you want to make the scope of certain members of your class as private as possible. So all those members that only your class will use, should be hidden to “the outside world”. This can be done by declaring a special type of category called “extension” (it can’t have a name, it’s declared as @interface Class () ), and the properties inside that extension (along with private method declaration if you want as well)
As to the question whether it’s a good practice, that may be discussed among different developers. To me, it is since it’s good OOP practice, and also because it helps keeping your header file as clean as possible (and so making it easier for other developers to see what “services” your class provides)