我想将以下创建游戏中心GKVoiceChat
的代码迁移到Swift中:
GKMatch* match;
GKVoiceChat *teamChannel = [[match voiceChatWithName:@"redTeam"] retain];
GKVoiceChat *allChannel = [[match voiceChatWithName:@"allPlayers"] retain];
我怀疑Swift代码看起来像这样:
var match: GKMatch!
func voiceChatWithName(name: String!) -> GKVoiceChat! {
return nil
}
但即使我搜索了文档,我也完全不知道它在Swift中是如何工作的。如何将上面的代码迁移到Swift?
答案 0 :(得分:1)
因此,在您的GKMatchmakerViewControllerDelegate
方法中,您应该能够执行以下操作:
func matchmakerViewController(_ viewController: GKMatchmakerViewController!,
didFindMatch match: GKMatch!) {
let teamChannel = match.voiceChatWithName("redTeam")
let allChannel = match.voiceChatWithName("allPlayers")
// use the channels above
}