1
为了读取对方的新显示名称,我需要终止并更新GKSession。将它设置为零并重新启动它不起作用。在下面的代码中,的NSLog在for循环以显示可用的同龄人不叫(没有错误消息):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);
}
什么是错的设置currentSession到零,重新开始呢? 也许你知道另一种更新GKSession的方法吗? 非常感谢。