- Home /
Is there a useful upper limit to the size of ArrayPrefs (PlayerPrefs) data?
I'm making a game for iOS which has a rather large set of records (high scores etc). For each of the 30 levels, there are 13 difficulty levels, and for each of those there are top tens of three different stats. All of that is for EACH player profile. So if there are 10 players, there could be up to 10 x 30 x 13 x 30 = 117,000 ints in the records. On top of that, there are other general saved preferences but the records will be the most bulk.
I figure I'll save the data at the end of each level, perhaps when losing a life and whenever the player pauses the game (as I want to save current game state too).
My question is: is this likely to result in a huge performance hiccup, using ArrayPrefs2? Using it would make coding simple. One alternative is to create a separate record file for each level for each player - but I'd rather avoid having to code my own I/O system if possible.
I'd appreciate any advice in advance of getting myself in a tangle!
Answer by Eric5h5 · Jan 14, 2013 at 08:13 PM
There isn't a maximum size, however PlayerPrefs just wraps NSUserDefaults, which is a plist file that's read and written as a whole, so storing that much data in it is far from efficient (and I don't know if it would cause issues trying to write it all when an app is shut down). You'd want to write separate files, preferably one per player per level. It's not really all that hard to write a system using the System.IO.File classes.
Very helpful as always Eric - thanks! In light of this I've decided to cut down vastly on the amount of records stored, and I've got it down to 36 ints per maze, so 1080 ints total for 30 mazes. Do you think that's still inefficient within PlayerPrefs?
That would be about 4$$anonymous$$ + some overhead, which seems reasonable.
Cool - that's good to know. I'll give it a go, and if it seems slow I'll have to make my own system. Thanks again!
Your answer
Follow this Question
Related Questions
PlayerPrefs aren't working in iphone 2 Answers
Does ArrayPrefs2 stores data on disk ? 0 Answers
I cannot store data into PlayerPrefs after a certain amount of data 2 Answers
Guide in ArrayPrefs or PlayerPrefx? 1 Answer
arrayPrefs playerPrefs 1 Answer