I am from C# background, and I am having a hard time in figuring out about how to use a static variable(BOOL in my case) in Objective C. My questions are:
Declare static variable in your implementation file and provide class method to set/get vlaue of it.
// MyClass.h
@interface MyClass : NSObject {
}
+ (BOOL)gBoolean;
+ (void)setGBoolean:(BOOL)value;
@end
// MyClass.m
#import "MyClass.h"
static BOOL gBoolean;
@implementation MyClass
+ (BOOL)gBoolean; {
return gBoolean;
}
+ (void)setGBoolean:(BOOL)value; {
gBoolean = value;
}
@end
Take a look at this answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With