The Problem In Brief
Trying to play with a friend in real-time using gamecenter causes a crash during gameplay
Project Details
My Investigation
-(void)matchmakerViewController: (GKMatchmakerViewController *) viewController didFindMatch:(GKMatch *)match
My Process For Handling Invites
{
-(void)player:(GKPlayer *)player didAcceptInvite:(GKInvite *)invite {
self->inviteStarted((int)invite.playerGroup);
NSLog(@"didAcceptInvite");
//Called when another player accepts a match invite from the local player.
NSLog(@"didAcceptInvite was called: Player: %@ accepted our invitation", player);
GKMatchmakerViewController *mmvc = [[[GKMatchmakerViewController alloc] initWithInvite:invite] autorelease];
mmvc.matchmakerDelegate = self;
[[AppController getViewController] presentViewController:mmvc animated:YES completion:nil];
}
}
{
-(void)matchmakerViewController:(GKMatchmakerViewController *)viewController didFindMatch:(GKMatch *)match
{
if (match != nil)
{
[[AppController getViewController] dismissViewControllerAnimated:YES completion:nil];
NSLog(@"%@", match);
self->myMatch = match;
//NSLog(@"Match found count!! %lu", (unsigned long)[self->myMatch retainCount]);
match.delegate = self;
if (!self->matchStarted && myMatch.expectedPlayerCount == 0)
{
self->matchStarted = YES;
opponent=[[myMatch players] objectAtIndex:0];
self->matchBegan();
[self loadOppPhoto];
}
}
}
}
{ -(void) sendDataToOppUnreliable:(NSString*)str
{
NSError *error=nil;
NSData *packet = [str dataUsingEncoding:NSUTF8StringEncoding];
//NSLog(@"this: %@", self);
//NSLog(@"Match found count!! %lu", (unsigned long)[self->myMatch retainCount]);
//NSLog(@"match: %@", self->myMatch);//EXC_BAD_ACCESS
[myMatch sendDataToAllPlayers: packet withDataMode:
GKMatchSendDataUnreliable error:&error];//EXC_BAD_ACCESS
if (error!=nil)
{
NSLog(@"Error in sending data: %li", (long)[error code]);
}
}
}
Thanks for the help :)