Just wanted to get a sanity check on this code for storing and retrieving user data for iOS 7. It's not working but I'm not seeing the issue.
GameData.h
#import <Foundation/Foundation.h>
@interface GameData : NSObject<NSCoding>
{
int HighScoreGD;
}
@property (readwrite,assign) int HighScoreGD;
@end
extern GameData *gGameData;
GameData.m
#import "GameData.h"
GameData *gGameData;
@implementation GameData
@synthesize HighScoreGD;
-(void)encodeWithCoder:(NSCoder *)coder {
[coder encodeInt:HighScoreGD forKey:@"HighScoreGD"];
}
-(id)initWithCoder:(NSCoder *)coder {
if((self = [super init])) {
HighScoreGD = [coder decodeIntForKey:@"HighScoreGD"];
}
return self;
}
-(id) init {
if((self = [super init])) {
}
return self;
}
-(void) dealloc {
//[super dealloc];
}
@end
Storing data:
gGameData.HighScoreGD = pointsHigh;
Retrieving data:
pointsHigh = gGameData.HighScoreGD;
I had used this in a bunch of old game concepts (cocos2d) in the past and it worked fine.
Not getting compile errors. Just simply isn't storing the data.
I haven't used this code in a couple years and it's not working. Did iOS7 or cocos2d v3 change how NSCoder is used?
Or am I making a dumb error somewhere?
Thanks in advance.