Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8922379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:49:05+00:00 2026-06-15T06:49:05+00:00

I am making a turn-based game where I have stored an integer variable ‘points’

  • 0

I am making a turn-based game where I have stored an integer variable ‘points’ into NSData, which is then stored by gamecenter. So far I am doing this as follows:

NSString *newString=[[NSString alloc] initWithFormat: @”%i”, points];

NSData *data = [newString dataUsingEncoding:NSUTF8StringEncoding];

I need to store more variables into NSData *data. How can i do this?

I am now aware that you can store 2 integers in the string *newString by:

NSString *newString=[[NSString alloc] initWithFormat: @”%i, %i”, points, otherInteger];

However I don’t know how I would decode this as the string would be stored as one integer value following on from the last. It might not be the best implementation anyway so any suggestions would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T06:49:07+00:00Added an answer on June 15, 2026 at 6:49 am

    You could do something like this:

    // for encoding
    int32_t points = ...;
    int32_t otherInteger = ...;
    NSMutableData *data = [NSMutableData data];
    [data appendBytes:&points length:sizeof(int32_t)];
    [data appendBytes:&otherInteger length:sizeof(int32_t)];
    .
    .
    .
    
    // for decoding
    NSData *data = ...;
    int32_t points;
    int32_t otherInteger;
    int index = 0;
    NSRange range;
    
    range = NSMakeRange(index, sizeof(int32_t));
    [data getBytes:&points range:range];
    index += sizeof(int32_t);
    
    range = NSMakeRange(index, sizeof(int32_t));
    [data getBytes:&otherInteger range:range];
    index += sizeof(int32_t);
    
    .
    .
    .
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am making a turn based hex-grid game. The player selects units and moves
I have some experience making multiplayer turn-based games using sockets, but I've never attempted
I'm making a Turn-Based game, and trying to figure out when the last turn
I'm making a turn based game, and trying to construct the matching function, when
I'm making a very simple turn based battle game using ActionScript 2.0. I'm VERY
I am making a tree which will eventually turn into a set of arms
I'm making a turn based rpg game with some multiplayer functions using GAE. I
I'm making a game that is Pixel-based in Android. I have several 8x8 sprites
For a project I am making a simple RPG turn based game in Android.
I'm making a turn-based RPG game, and my method that sorts all Actor objects

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.