In a game I am working on I have implemented GKSavedGames and everything is working correctly except that if the game is uninstalled and reinstalled or installed on a new device the first initial launch fetchSavedGamesWithCompletionHandler
returns 0 saved games.
Is there a way to force iCloud to sync the files to the device? I have tried waiting and recalling fetchSavedGamesWithCompletionHandler
but nothing seems to work. If I immediately relaunch the app all the save files are then available.
I'm not familiar with GKSavedGames
, but if you are using CloudKit as your post's tag implies, then the following approach may help you.
UserDefault
with type Date
named something like lastUpdated
.lastUpdated
is nil
(which it will be on a fresh installation of a device) then do a CKQuery
to fetch all records.lastUpdated
to "now" using a new Date()
object.lastUpdated
date in the future to check for stale data. For example, if lastUpdated
is more than n
days old compared to now, you can pull the records again.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.