I am trying to declare a UInt32 variable that can be accessed by any method in the class..
so its global to the classes methods but not to any other class…
I am trying to do it like this in the .h
@interface EngineRequests : NSObject {
UInt32 dataVersion;
}
@property (copy) UInt32 dataVersion;
but thats not working.. I’m getting an error on the line @property etc.. do I even need that or is it fine to just use the UInt32 at the top.
You could try
But you don’t really need the property, unless you want to grant/control outside access. You could just declare
UInt32 dataVersionin the class interface and then referencedataVersionin the implementation withoutself.Either way,@protectedwill prevent outside classes from accessingdataVersiondirectly.Have you read up on Objective-C Properties?
Initialization
Your
EngineRequestsis a subclass ofNSObject. As such, you can (usually should) overrideNSObject‘s-(id)initmethod, like such:Or create your own
-(id)initWithVersion:(UInt32)version;.