Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Mobile Development > BOOK: Beginning iOS Game Development
|
BOOK: Beginning iOS Game Development
This is the forum to discuss the Wrox book Beginning iOS Game Development by Patrick Alessi ; ISBN: 978-1-1181-0732-4
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning iOS Game Development section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 1st, 2012, 10:29 PM
Registered User
 
Join Date: Aug 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation Chapter 10 - TicTac...Crashing due to exception

...later...

Section missing in the book!!! ...on <NSCoding>

GameState.h

//
// GameState.h
// TicTac
//
// Created by Alessi Patrick on 8/26/11.
// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>

typedef enum {
TTxPlayerTurn = 1, // The x player's turn
TToPlayerTurn = 2 // The o player's turn
} TTPlayerTurn;


@interface GameState : NSObject <NSCoding>
{
TTPlayerTurn playersTurn;
NSMutableArray* boardState;

}

@property TTPlayerTurn playersTurn;
@property (strong, nonatomic) NSMutableArray* boardState;


@end

GameState.m

//
// GameState.m
// TicTac
//
// Created by Alessi Patrick on 8/26/11.
// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
//

#import "GameState.h"

@implementation GameState
@synthesize playersTurn,boardState;


-(id) init
{
self = [super init];

if (self) {
// Alloc and init the board state
boardState = [[NSMutableArray alloc] initWithCapacity:9];

playersTurn=TTxPlayerTurn;

}

return self;

}


#pragma mark NSCoding methods
- (void)encodeWithCoder:(NSCoder *)aCoder
{

[aCoder encodeObject: boardState forKey:@"BoardState"];
[aCoder encodeInt:playersTurn forKey:@"PlayersTurn"];
}

- (id)initWithCoder:(NSCoder *)aDecoder
{
boardState = [aDecoder decodeObjectForKey:@"BoardState"];
playersTurn = [aDecoder decodeIntForKey:@"PlayersTurn"];

return self;

}

@end

Last edited by michel14343; September 1st, 2012 at 10:53 PM..





Similar Threads
Thread Thread Starter Forum Replies Last Post
Null Reference Exception Listing 1-10 tomche BOOK: Professional C# 4.0 and .NET 4 1 October 21st, 2011 04:31 PM
Chapter 10, listing 10-10-app kiwibrit BOOK: Professional ASP.NET 3.5 : in C# and VB ISBN: 978-0-470-18757-9 2 August 18th, 2009 04:21 AM
Chapter 10 exception error JohnBoy BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 4 August 1st, 2007 03:27 PM
Chapter 3, cannot build due to health monitoring stzd8 BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 9 May 11th, 2007 04:18 PM
Chapter 10 system exception error dkelly BOOK: Beginning VB.NET Databases 1 July 28th, 2005 04:07 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.