通过GameKit将游戏数据保存到iCloud中 [英] Save game data into iCloud via GameKit

查看:621
本文介绍了通过GameKit将游戏数据保存到iCloud中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过下一代码将游戏数据保存到iCloud:

I'm trying to save game's data to iCloud via next code:

GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
[localPlayer saveGameData:[NSData dataWithBytes:rawData->data() length:rawData->size()]
                 withName:[NSString stringWithUTF8String:fileName.c_str()]
        completionHandler:^(GKSavedGame *savedGame, NSError *error) {
            if (error == nil) {
                DebugLog(@"Snapshot successfully saved");
            } else {
                DebugLog(@"saveSnapshot error: %@", error.description);
            }
        }];

但收到错误消息:无法完成请求的操作,因为你是没有登录iCloud

But getting error message: The requested operation could not be completed because you are not signed in to iCloud

我试过在iOS模拟器和设备上做这个但是没有不会成功。


并尝试使用测试苹果ID,开发苹果ID,新苹果ID,但也没有成功。


用户在iOS设置中登录iCloud并登录到Game Center。


$
有什么建议吗?

I've tried to do this in iOS Simulator and on device but didn't succeed.
And tried to use test apple ID, dev apple ID, new apple ID, but didn't succeed too.
User is logged in to iCloud in iOS Settings and logged in to Game Center.

Any suggestions?

推荐答案

我有类似的问题。在我的设备设置上使用我的iCloud帐户登录后,仍然显示完全相同的错误,并且只有在我为帐户启用iCloud Drive时才会停止,否则它将无法正常工作。

I had a similar issue. After I signed in with my iCloud account on my device's settings, the exact same error was still showing up, and it only stopped when I enabled the iCloud Drive for my account, otherwise it will never work.

所以,看起来用户必须使用iCloud Drive,否则GKSavedGame永远不会工作。据我所知,Apple文档从未提及过。

So, it looks like the user must be using iCloud Drive, otherwise GKSavedGame will never work. Apple docs never mention that as far as I'm aware.

这篇关于通过GameKit将游戏数据保存到iCloud中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆