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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:31:00+00:00 2026-06-17T04:31:00+00:00

It might be the simplest Question, but at this time ,I am not getting

  • 0

It might be the simplest Question, but at this time ,I am not getting any Idea on how to implement this.

Ok, The problem is of how to concatenate two integers.

For Eg: I want to create an integer say 0000 using two different integers 00 and 00. I tried using NSString , but I failed.

My Code is :

                int num1 = 00;
                int num2 = 00;
                NSString *str = [NSString stringWithFormat:@"%d%d",num1,num2];
                int num = [str intValue];
                NSLog(@"num = %d",num); // It Logs 0 but I want 0000.

Does anyone have better Idea ?

EDIT :

Please Note that , I want to use that num to set the tag of textfield. That’s why all the zeros are essential. So my main Problem starts here.

I have one tableview which contains custom cells. This custom cell has more than 10 textfields. Now I want to uniquely identify all the textfields for editing. That’s why the tag for that textfield must be the integer concatenated by two values called rowNumber and textFieldNumber (means which textField out of 10.).

So my question is what I am trying to do is right or not ? And if not then give me some useful solution.

  • 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-17T04:31:02+00:00Added an answer on June 17, 2026 at 4:31 am

    The integer data types (such as int) only store the integer value, not formatting information. Therefore you lose the number of leading zeroes (which do not affect the integer value, i.e., 0, 00, and 0000 are the same integer: zero).

    If you wish to retain formatting information, you must store it separately. A simple way is to just store the string itself. Or, if you always want to have the same number of digits, then alter the formatting string:

    int num1 = 0;
    int num2 = 0;
    NSString *str = [NSString stringWithFormat:@"%02d%02d",num1,num2];
    

    After the above code, str will be "0000". However, converting it to int and then logging with %d formatting results in 0 once more (since 0000 and 0 are the same integer).

    Edit: For the purpose of generating unique integers for tagging purposes, given a row number (rowNumber) and text field number (textFieldNumber), use a formula like:

    tagNumber = rowNumber * 100 + textFieldNumber;
    

    This way the text fields of row 0 will have numbers 0..99, those on row 1 will have 100..199, etc. If more than 100 text fields are required per row, simply multiply by a larger number, like 1000.

    In integer arithmetic these values can be converted back to row and field numbers with:

     rowNumber = tagNumber / 100;
     textFieldNumber = tagNumber % 100;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This may be the simplest question ever, but try as I might I simply
Might be a bit of noob question but it's something that's been getting me
This might seem like a very easy question for some of you folks, but
This might be a simple question but I've searched and searched and can't find
This might sound like a trivial question to a lot of people, but since
Might be my question sounds more naive. But I wanted to know if it
Might be my question is abstract or out of context, but i am asking
might be a stupid question but I seem to be confused. Im pretty new
Might be a stupid question but in our iOS app we're storing an integer
It might look like a stupid question, but I recently realized that .NET implementation

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.