我目前正在尝试将目标C的游戏中心教程翻译成Swift,我遇到了障碍。我一直在寻找大约一个小时,但是找不到任何有用的东西来帮助我翻译这个回调方法:
- (void)matchmakerViewController:(GKMatchmakerViewController *)viewController didFailWithError:(NSError *)error {
[viewController dismissViewControllerAnimated:YES completion:nil];
NSLog(@"Error finding match: %@", error.localizedDescription);
很抱歉,如果这很容易(很可能)。我是Swift的新手,很想得到一些帮助.. 先谢谢!
答案 0 :(得分:1)
Apple已将大部分文档更新为包含Swift和Objective-C版本的API,因此您可以查看GKMatchmakerViewControllerDelegate methods there。这个功能是:
func matchmakerViewController(viewController: GKMatchmakerViewController!, didFailWithError error:NSError!) {
viewController.dismissViewControllerAnimated(true, completion: nil)
println("Error finding match: \(error.localizedDescription)")
}