У меня большие проблемы с отправкой данных между устройствами из многопользовательской игры Game Center. Я могу установить совпадение и подключить обоих пользователей, но по какой-то причине я не могу отправить данные. Вот мой код:
-(void)sendData {
NSError *error;
int myScore = scoreInt;
NSData *packet = [NSData dataWithBytes:&myScore length:sizeof(myScore)];
[theMatch sendDataToAllPlayers: packet withDataMode: GKMatchSendDataUnreliable error: &error];
if (error != nil)
{
NSLog(@"ERROR: %@", error);
}
}
-(void)match:(GKMatch *)match didReceiveData:(NSData *)data fromPlayer:(NSString *)playerID {
NSLog(@"called");
}
Я несу свой матч с другого вида, и я не знаю, проблема ли в этом, но вот код, когда игровой центр находит матч:
- (void)matchmakerViewController:(GKMatchmakerViewController *)viewController didFindMatch:(GKMatch *)match
{
MultiplayerView *mpv = [[MultiplayerView alloc] init];
[self dismissModalViewControllerAnimated:NO];
mpv.theMatch = match; // Use a retaining property to retain the match.
match.delegate = self;
NSLog(@"Matched");
if (!self.matchStarted && match.expectedPlayerCount == 0)
{
self.matchStarted = YES;
NSLog(@"Lets Go");
MultiplayerView *mpv = [[MultiplayerView alloc] init];
[mpv setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
[self presentModalViewController:mpv animated:YES];
}
}
Любые идеи?