ios - Store NSArray in persistent (user) data -


i need make inventory array persistent (does not reset each time app closed , reopened). use gamestate singleton class store high score, player level, etc. these have been integers far , pretty straight forward use.

i followed attached tutorial regards gamestate singleton class: http://www.raywenderlich.com/63578/make-game-like-mega-jump-spritekit-part-22

i need store array of inventory custom skspritenode subclass.

can store array in singleton class , syntax need approach that?

in order save array need set encoding/decoding? saw different approach seems way more complicated singleton class.

i versed in sql prefer not use sqllite if can instead retrieve array directly if stored locally.

nsuserdefaults knows nsdata, nsstring, nsnumber, nsdate, nsarray, , nsdictionary, easiest thing store data need save in combination of data types. if can't that, you'll need implement nscoding in custom class can archive instances nsdata objects, isn't hard sounds: http://sam.roon.io/archiving-objective-c-objects-with-nscoding.

personally, i'd start splitting model view (take "data" part of sprite kit objects , put them separate, data-only classes or structs). should make easier reason needs serialized.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -