i implemented Trivia game for both iphone/iPad when user completes the game i am sending score to the opponent.i am not getting correct result won/loose .if i am playing the game simultaneously both users i am getting correct result who won/loose the game .
how to resolve this issue can any one suggest me .i implemented bluetooth option via Gamekit API
- (void)receiveData:(NSData *)data fromPeer:(NSString *)peer inSession: (GKSession *)session context:(void *)context
{
//Convert received NSData to NSString to display
NSString *whatDidIget = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
//Dsiplay the fart as a UIAlertView
int abc=[whatDidIget integerValue];
if(a>abc)
{
UIAlertView *alert55 = [[UIAlertView alloc] initWithTitle:@"Apponent Score:looser" message:whatDidIget delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert55 show];
[alert55 release];
[whatDidIget release];
}
else {
UIAlertView *alert55 = [[UIAlertView alloc] initWithTitle:@"Apponent Score:Win" message:whatDidIget delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert55 show];
[alert55 release];
[whatDidIget release];
}
}
button clicking code
- (void) sendASilentAssassin{
// Making up the Silent Assassin :P
NSString *silentAssassin = @"Puuuuuuuusssssssssssssssss";
// Send the fart to Peers using teh current sessions
[triviaSession sendData:[displayLiveScore.text dataUsingEncoding: NSASCIIStringEncoding] toPeers:triviaPeers withDataMode:GKSendDataReliable error:nil];
}
No comments:
Post a Comment