How can I set a global class containing sharedInstance and also how can I get and change the variable within from each viewcontroller?
The following is my code:
DataClass.h:
@interface DataClass : NSObject {
int *toyid;
}
+(DataClass *)sharedInstance;
@end
DataClass.m:
@implementation DataClass
+(DataClass *)sharedInstance {
static DataClass *myData = nil;
if(nil == myData) {
myData = [[[self class] alloc]init];
myData.toyid=0;
}
return myData;
}
@end
Please help