You could try
@interface EngineRequests : NSObject {
@protected
UInt32 dataVersion;
}
@property (assign) UInt32 dataVersion;
@end
@implementation EngineRequests
@synthesize dataVersion;
// methods can access self.dataVersion
@end
But you don't really need the property, unless you want to grant/control outside access. You could just declare UInt32 dataVersion
in the class interface and then reference dataVersion
in the implementation without self.
Either way, @protected
will prevent outside classes from accessing dataVersion
directly.
Have you read up on Objective-C Properties?
Initialization
Your EngineRequests
is a subclass of NSObject
. As such, you can (usually should) override NSObject
's -(id)init
method, like such:
-(id)init {
self = [super init];
if (self != nil) {
self.dataVersion = 8675309; // omit 'self.' if you have no '@property'
}
return self;
}
Or create your own -(id)initWithVersion:(UInt32)version;
.