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 9300625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T22:49:26+00:00 2026-06-18T22:49:26+00:00

How do I concatenate the int length to the string I’m trying to slap

  • 0

How do I concatenate the int length to the string I’m trying to slap into that array so it is “C10” given length == 10, of course. I see @"%d", intVarName way of doing it used else where. In Java I would of done "C" + length;. I am using the replaceObjectAtIndex method to replace the empty string, “”, that I have previously populated the MSMutableArray “board” with. I am getting an error though when I add the @"C%d", length part at the end of that method (second to last line, above i++).

As part of my homework I have to randomly place “Chutes” (represented by a string of format, “C’length_of_chute'”, in this first assignment they will always be of length 10 so it will simply be “C10”) onto a game board represented by an array.

   -(void)makeChutes: (int) length {// ??Change input to Negative number, Nvm.
    //??Make argument number of Chutes ??randomly?? across the board.
    for(int i = 0; i < length;){
        int random = arc4random_uniform(101);
        if ([[board objectAtIndex:random] isEqual:@""]) {
            //[board insertObject:@"C%d",length atIndex:random];
            [board replaceObjectAtIndex:random withObject:@"C%d",length];
            i++;
        }
    }
}

Please ignore the extra and junk code in there, I left it in for context.

  • 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-18T22:49:27+00:00Added an answer on June 18, 2026 at 10:49 pm

    In Objective-C the stringWithFormat method is used for formatting strings:

    NSString *formattedString = [NSString stringWithFormat:@"C%d", length];
    [someArray insertObject:formattedString];
    

    It’s often easier to create your formatted string on a line of its own in Objective-C, since as you can see the call can be fairly verbose!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to concatenate two properties into one string like so: public class thing
I am trying to concatenate two arrays into new array, sort in order, and
Possible Duplicate: Concatenate Two NSDate String values Just confused that is there any default
I'm trying to return all possible permutations of values in a String array. I've
Possible Duplicate: C++ concatenate string and int Hi, In C# I can write like
Possible Duplicate: C++ concatenate string and int I am tryinging to make use many
I was trying to implement a simple function that can concatenate any number of
I have the following method: /** * Encodes the byte array into base64 string
I need to concatenate different lines in a string. To do so, I need
I am trying to create a method that pretty much takes anything as a

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.