我希望使用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...