1
ピアの新しい表示名を読み取るには、GKSessionを強制終了して更新する必要があります。これをnilに設定して新たに起動することはできません。GKSession - セッションを終了して更新する
-(IBAction) btnRefresh:(id) sender {
self.currentSession = nil;
self.currentSession = [[GKSession alloc] initWithSessionID:@"anything" displayName:name sessionMode:GKSessionModePeer];
self.currentSession.delegate = self;
self.currentSession.available = YES;
self.currentSession.disconnectTimeout = 0;
[self.currentSession setDataReceiveHandler:self withContext:nil];
peerListAvailable = [[NSMutableArray alloc] initWithArray:[currentSession peersWithConnectionState:GKPeerStateAvailable]];
for (NSString *peer in peerListAvailable) {
NSLog(@"found available peer; checking name and ID... %@, %@",[currentSession displayNameForPeer:peer], peer);
}
何nilにcurrentSessionを設定すると間違っていると改めてそれを開始:以下のコードでは、forループ可能なピアを表示する中のNSLogが呼び出されません(エラーメッセージはありませんか)? GKSessionを更新する別の方法が分かっているのでしょうか? ありがとうございます。