2012-06-06 3 views
2

게임 센터 멀티 플레이어에서 장치간에 데이터를 보내는데 많은 문제가 있습니다. 나는 성냥을 만들 수 있고 양쪽 사용자가 연결되어있다 그러나 나는 자료를 보낼 수 없다. 게임 센터는 경기가 발견 한 경우게임 센터에서 데이터 송수신

-(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]; 
    } 
} 

어떤 아이디어?

+0

데이빗 불 라드 (David Bullard) 같은 문제가 있습니다. http://stackoverflow.com/questions/12641113/issues-regarding-gamecenterios. 그러나 답변을 얻지 못했습니다. me.if 도움이 질문에 대한 답변을 얻으실 수 있습니다. –

답변

1

일치하는 사람에게 현재보기 컨트롤러를 지정해야합니다. 그렇지 않으면 match : didReceiveData : fromPlayer :가 작동하지 않습니다.

+0

예! 고마워. (런타임이 nil delegate에 대해 불평하면 두려울 것입니다) – buildsucceeded

관련 문제