ios – GKLocalPlayer和saveGameData的问题

前端之家收集整理的这篇文章主要介绍了ios – GKLocalPlayer和saveGameData的问题前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想使用GKLocalPlayer和saveGameData方法保存游戏数据.
[localPlayer saveGameData:playerData withName:@"SolarFlares" completionHandler:^(GKSavedGame *savedGame,NSError *error) {
    if (savedGame != nil) {
        NSLog(@"Player data saved to GameCenter");
    }else{
        NSLog(@"Player=%@ data NOT saved to GameCenter,error=%@",localPlayer,error.description);
    }
}];

上面的代码在xcode模拟器上工作正常,但是当我在iPhone上尝试时,会收到如下所示的错误代码.我无法理解这一点.我无法控制在哪里可以保存游戏数据,所以为什么系统试图在没有权限的情况下保存它?

Error Domain=NSCocoaErrorDomain Code=513 "The operation couldn’t be completed. (Cocoa error 513.)" UserInfo=0x171661f80
{NSFileOriginalItemLocationKey=file:///private/var/.DocumentRevisions-V100/PerUID/501/e4/com.apple.ubiquity/iCloud~com~MJinc~SolarFlares_A3695FA3-6BFA-4862-B53A-F01E192726CC_1a.bundle/,NSURL=file:///private/var/.DocumentRevisions-V100/PerUID/501/e4/com.apple.ubiquity/iCloud~com~MJinc~SolarFlares_A3695FA3-6BFA-4862-B53A-F01E192726CC_1a.bundle/,NSFileNewItemLocationKey=file:///private/var/mobile/Containers/Data/Application/EF8BC999-1D4B-42B2-B8D9-0B0A79543C03/tmp/(A%20Document%20Being%20Saved%20By%20Solar%20Flares)/iCloud~com~MJinc~SolarFla
res_A3695FA3-6BFA-4862-B53A-F01E192726CC_1a.bundle,NSUnderlyingError=0x170c48b50 "The 
operation couldn’t be completed. Permission denied"}

// Micke …

解决方法

我改变了SaveGame的名字,错误消失了.

猜你在找的iOS相关文章