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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:06:53+00:00 2026-05-18T10:06:53+00:00

I am working on an iPhone app that is using some urls and I

  • 0

I am working on an iPhone app that is using some urls and I am running into difficulty appending ints onto the end of them. I have the following line of code

        NSURL *urlCards = [[NSURL alloc] initWithString:(@"http://website.edu/get_stuff/%@",[NSString stringWithFormat:@"%d",_stuffID])];

that I need to simply be appending an int to the end of. When I print out the results of the NSURL urlCards, I simply get the value of the int that I am passing in, or the value of _deckID.

I have verified that the _deckID which is declared merely as a local int does indeed have the correct value at run time.

What am I missing?

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-18T10:06:54+00:00Added an answer on May 18, 2026 at 10:06 am

    What you’ve encountered is the comma operator. The comma operator evaluates each of its operands for their side effects, and evaluates to the result of the last expression. For example:

    int i;
    int j;
    int z;
    
    z = (i = 4, j = 3, i + j);
    // z is now 7
    

    What you’ve got here:

    (@"http://website.edu/get_stuff/%@",[NSString stringWithFormat:@"%d",_stuffID])
    

    Evaluates to just

    [NSString stringWithFormat:@"%d", _stuffID]
    

    This is because the first part @"..." is an expression that has no side effects, and the result of the comma operator is the result of the [NSString stringWithFormat:] method.

    What you are looking for I think, it this:

    NSString *urlString = [NSString stringWithFormat:@"http://website.edu/get_stuff/%d",_stuffID];
    NSURL *urlCards = [[NSURL alloc] initWithString:urlString];
    

    You can also do it in one line, like KingofBliss’s answer.

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

Sidebar

Related Questions

I am working on an iPhone app that has to post some data to
In an iPhone app I'm working on, the user needs to enter some configuration
I'm working on an iPhone app that gets a number of objects from a
I'm working on an iPhone App that relies heavily on OpenGL. Right now it
I'm working on an iPhone app that, at a certain point, will try to
I have been working on an iPhone app that has a feature of uploading
I'm working on a largely navigation-based iPhone app that communicates with a REST API
I'm working on a simple iPhone app. I have 1 UINavigationController and 2 subclasses
I'm working on an iphone application (not web app) and I'd like to build
I'm working on an iPhone game that takes place on the ocean surface. Can

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.