I am wring a class that has a bunch of properties that I want to only use internally. Meaning I don't want to be able to have a user access them when they have created my class. Here is what I have in my .h but it still doesn't hide those from the autocomplete menu (hitting escape to see list) in XCode:
@interface Lines : UIView {
UIColor *lineColor;
CGFloat lineWidth;
@private
NSMutableArray *data;
NSMutableArray *computedData;
CGRect originalFrame;
UIBezierPath *linePath;
float point;
float xCount;
}
@property (nonatomic, retain) UIColor *lineColor;
@property (nonatomic) CGFloat lineWidth;
@property (nonatomic) CGRect originalFrame;
@property (nonatomic, retain) UIBezierPath *linePath;
@property (nonatomic) float point;
@property (nonatomic) float xCount;
@property (nonatomic, retain) NSMutableArray *data;
@property (nonatomic, retain) NSMutableArray *computedData;
I thought that using @private
was what I needed, but maybe I have done it wrong. Does something need to also be done in my .m?
@private
only affects ivars. It doesn't affect properties. If you want to avoid making properties public, put them in a class extension instead. In your .m file, at the top, put something likeThis looks like a category, except the category "name" is blank. It's called a class extension, and the compiler treats it as if it were part of the original @interface block. But since it's in the .m file, it's only visible to code in that .m file, and code outside it can only see the public properties that are declared in the header.