★ TouchArcade needs your help. Click here to support us on Patreon.

Right way to cache GKScores

09-02-2012, 01:17 PM
#1
Joined: May 2012
Posts: 38
Right way to cache GKScores

Hi!

I'm adding game center support to my game and I was wondering what's the right way to cache scores. According to the apple guide, GKScores can be cached using the NSCoding protocol then restored after.

However if the date the score was achieved isn't of any important use, wouldn't be better to just create a new GKScore object everytime instead of caching it? The advantage with this method is that it's harder to hack and easier to implement.

Any advice is welcome
09-04-2012, 08:39 AM
#2
Joined: Feb 2012
Posts: 24
Quote:
Originally Posted by Ologon View Post
Hi!

I'm adding game center support to my game and I was wondering what's the right way to cache scores. According to the apple guide, GKScores can be cached using the NSCoding protocol then restored after.

However if the date the score was achieved isn't of any important use, wouldn't be better to just create a new GKScore object everytime instead of caching it? The advantage with this method is that it's harder to hack and easier to implement.

Any advice is welcome
A GKScore contains more than just time. It also contains the PlayerID.

How do you expect to submit a score without a valid PlayerID?
Or...do you want to submit a score that belongs to another player?

So, if Apple says store the whole thing, then I recommend doing it.

And if you want to protect it, use NSData to store a hash to prevent tampering.

Last edited by Devcade; 09-04-2012 at 02:03 PM.