繁体   English   中英

如何将此GKVoiceChat代码迁移到Swift?

[英]How do I migrate this GKVoiceChat code to Swift?

我想将以下创建Game Center 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?

因此,在您的GKMatchmakerViewControllerDelegate方法中,您应该能够执行以下操作:

func matchmakerViewController(_ viewController: GKMatchmakerViewController!,
                      didFindMatch match: GKMatch!) {

    let teamChannel = match.voiceChatWithName("redTeam")
    let allChannel = match.voiceChatWithName("allPlayers")

    // use the channels above
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM