Problems with GKLocalPlayer and saveGameData

985 views Asked by At

I want to save game data with GKLocalPlayer and saveGameData method.

[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);
    }
}];

The code above works fine on the xcode simulator, but when I try it on my iPhone I get the error code shown below. I can't figure this out. I have no control over where it saves the game data so why are the system trying to save it where it has no permission!?!

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...

1

There are 1 answers

0
Oli On

I changed the SaveGame name and the error has disappeared.