Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (id)initWithCoder:(NSCoder *)decoder {
- self = [super init];
- if (!self) return nil;
- NSData *data = [decoder decodeObjectForKey:@"xoSpots"];
- if (data) {
- int *temporary = (int*)[data bytes];
- for(int i = 0; i < 9; ++i) xoSpots[i] = temporary[i];
- }
- if (!data) [self startAnew];
- self.tillCatsGame = [decoder decodeIntForKey:@"count"];
- self.playersTurn = [decoder decodeIntForKey:@"turn"];
- if (!playersTurn) playersTurn = BMPlayerTypeX;
- return self;
- }
- - (void)encodeWithCoder:(NSCoder *)encoder {
- [encoder encodeObject:[NSData dataWithBytes:(void*)xoSpots length:9*sizeof(int)] forKey:@"xoSpots"];
- [encoder encodeInt:self.tillCatsGame forKey:@"count"];
- [encoder encodeInt:self.playersTurn forKey:@"turn"];
- }
Advertisement
Add Comment
Please, Sign In to add comment