Reputation: 235
I want to create an interface with this signature, but without auto-synthesized instance variables:
@interface MyObject : NSObject
@property (nonatomic, copy) NSArray *values;
@end
Is it possible to prevent instance variable to be auto synthesized in .m @implementaion, as I want to implement my own getter and setter and I'm not going to use instance variable.
The reason is that I don't want to have memory overhead, as data is going to be stored in plain bytes archive. At the same time I don't want users to know implementation issues and keep interface signature unchanged.
@implementation MyObject {
NSData *_data
{
- (NSArray *)values
{
// Generate NSArray from _data
}
- (void)setValues(NSArray *)values
{
// Set _data from values
}
#pragma mark - Hidden init
- (id)initWithData:(NSData *)data
{
// Set _data
}
@end
Upvotes: 0
Views: 101
Reputation: 15035
If you dont wantbto create just create only instance variable.
@interface MyObject : NSObjet
{
NSArray *values;
}
@end
Upvotes: 0
Reputation: 7370
As others said - if you override the setter and getter - the compiler does't do anything else. So what you want.. is what you have typed out.
Upvotes: 0
Reputation: 7814
If you implement both getter and setter yourself, instance variables are not synthesized.
Upvotes: 2