about percentComplete in GKAchievement

2019-06-22 13:37发布

问题:

After testing, I find that though the type of percentComplete of GKAchievement is double, and in apple's help document the legal values is between 0.0 and 100.0. but if you report percentComplete=1.5 to apple server, next time you will get the value percentComplete=1.0(another example, report 0.5, get 0.0). So I just think this may be a bug of percentComplete. Now our project has some achievements need be accumulated, like finish 200 times of play, we
don't save the value in local, but report current counted times to apple server, for next time's calculation.

I just tested in SandBox with iOS 4.2, I don't know whether it only occurs in SandBox, so does anybody also find this problem, what's your workround?

回答1:

Answer from Apple: "The percentages are reported using doubles but stored as whole number percentages, e.g. 1%, 2%, 3%, ..., 100%.
You should probably store the progress locally anyways, since they might be someplace they can't connect to Game Center."

For those with access to Apple dev forums: https://devforums.apple.com/message/522769