Saving data on all devices

I am still in the early stages of the game, and I am saving information using the KeyChain wrapper class created by someone. I wanted to ask for advice at an early stage, since I have time to change my approach.

My game has the potential to save enough information about the player and what they did, for example:

  • how much gold does the player have
  • what items they purchased (you can get about 50 items)
  • what skills, spells and abilities did they choose for their character
  • what level of experience they have, maximum health, statistics, etc.

The reason I decided to keep this in KeyChain was because they told me that it was encrypted and it was much harder to intervene. I felt that there were other solutions, such as the ones below, but I wrote some potential reasons why this might not be good:

  • Do everything on a web server and store it in a database somewhere on my server . I want my game to be available offline.

  • Use a local database (e.g. FMDB) . I could use the tool to directly edit the values ​​and provide more health, etc.

  • Use master data . Never used it before, not sure if this is the same ease of substitution as # 3?
  • GameCenter - , ,
  • NSPreferences. ( )

, , , , KeyChain - . , , - , ? , ? JSON - (? GameCenter?)

/ , , .

, !

+4
2

, (, " " ), ( ) .:)

: ( ), ( ) .

  • Playable offline:

, - . Keychain, Core Data, SQL, NSPreferences - . Keychain, , / .

  • :

, , . https://developer.apple.com/library/content/documentation/Security/Conceptual/keychainServConcepts/02concepts/concepts.html http://evgenii.com/blog/sharing-keychain-in-ios/ , , .

Core Data, SQL , , . : https://developer.apple.com/library/content/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html

NSPreferences , . , , Linux- , , , .

, , " ". , , , . , : , , . , /, , , ( , ).

; , / .

  • :

. iCloud Keychain , , , , , . , , . , SO : fooobar.com/questions/101272/.... Apple (https://support.apple.com/en-us/HT204085), , .

Apple GameCenter CloudKit. . GameCenter CloudKit . CloudKit GameCenter, , .

GameCenter . , , . GameCenter GKTurnBasedMatch , SO, .

CloudKit - . iCloud "" . "private" () ( ) . WWDC CloudKit . , GameCenter, /. , iCloud .

(aka TL; DR)

, : , , , 1 req, , . Apple (), . , NSData cloudKit . GameCenter .

+3

!!

- . , UserDefaults . , iCloudKit, plist json AlamoFire, ..

, , CoreData.. ! NSCoder NSKeyedArchiver.

/, , UserDefaults.

, dicts UserDefaults ( )

Key:

 Items->Equipment->Weapons->WeaponName

:

 { dictionary of data like AP, Cost, etc }

, NSCoder , , , CoreData! , , UserDefaults, .

for, , , . , , UserDefaults.standard.dictionaryRepresentation, "Items- > Equipment" ..

, !

, , .

UPDATE: -, , , .

. , , , , .

GameCenter, GC , , / .

+2

Source: https://habr.com/ru/post/1664026/


All Articles