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

  • Home
  • SEARCH
  • 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 6106157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:02:59+00:00 2026-05-23T14:02:59+00:00

Clarification question here. I was originally attempting to concatenate two strings using the stringByAppendingString

  • 0

Clarification question here.
I was originally attempting to concatenate two strings using the stringByAppendingString method:

NSString *dataString = @",";
NSInteger i = 0;
NSString *cycleCountString = @"";
for (i = 0; i<[[self cycleList] count]; i++) {

    cycleCountString = [NSString stringWithFormat:@"cycle#%d,",i];
    [dataString stringByAppendingString:cycleCountString];
}
NSLog(@"DataString is: %@",dataString);

However, the NSLog was just outputing “,” as if cycleCountString was not being appended to dataString.

After reading:http://stackoverflow.com/questions/510269/how-do-i-concatenate-strings-in-objective-c , I was able to fix the issue by instead doing a stringWithFromat:

NSString *dataString = @",";
NSInteger i = 0;
NSString *cycleCountString = @"";
for (i = 0; i<[[self cycleList] count]; i++) {

    cycleCountString = [NSString stringWithFormat:@"cycle#%d,",i];
    dataString = [NSString stringWithFormat:@"%@%@",dataString,cycleCountString];


}
NSLog(@"DataString is: %@",dataString);

any idea why the previous method wasn’t working? Does stringByAppendingString not work the way I think it does?

thanks!

  • 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-05-23T14:02:59+00:00Added an answer on May 23, 2026 at 2:02 pm

    You’re never updating the value of dataString.

    dataString = [dataString stringByAppendingString: cycleCountString];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For clarification, here's the exact question in the about_regular_expressions.rb file that I'm having trouble
Quick question/clarification required here. I have a DB table that will quite possibly have
An ethical question here. I'm planning on using several manager classes in my new
Clarification/summary for the question -- we're looking for: a hosted bug tracking system, that
(If anything here needs clarification/ more detail please let me know.) I have an
I was trying to get clarification on this: Method-1: Dim request = CreateRequest(uri) //some
Bounty clarification I know it's a subjective question. The ideal answer I'm looking is
Aight, did a bit of Googling and searching here, the only question I found
This is related to this question here, but with a slight twist: instead of
I found the question here: Create GUID / UUID in JavaScript? The answer provides

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.