HomeForumsGeneral DiscussionSaving an array of integers with the gamestate

This topic has 2 voices, contains 2 replies, and was last updated by  udca 164 days ago.

Viewing 3 posts - 1 through 3 (of 3 total)
Author Posts
Author Posts
November 29, 2011 at 8:30 pm #571

udca

Hi, I’m trying to save my player’s skill information. Right now, I have 10 skills and I want to keep the level of each skill in an array (ex : skillLevel[0] = 3, skillLevel[2] = 1 etc.)

I’m having a hard time figuring out how to save arrays in the gamestate. It doesn’t seem to be supported, but I don’t understand why. Honestly, I don’t really know where to start. I’ve added other values in the gamestate without a problem, but these arrays really bug me. Any help would be very appreciated!

November 29, 2011 at 9:15 pm #2174

CyberGreg

NSCoding (& NSEncoder) requires that items are “objects” eg NSNumber, NSDictionary, etc. What you could do is load your integer array into an NSArray in your save method and reload your integer array in your load method.

December 6, 2011 at 5:40 pm #2194

udca

Got it working! Thanks a lot! :)

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.