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

The Archive Base Latest Questions

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

I am trying to code a textField so that is someone put in the

  • 0

I am trying to code a textField so that is someone put in the number 1 only it will show up 10 and if the put in the number 01 it will show up 01.
The problem I have is that when I code an if statement it can’t seem to read the 0 at the start of the number so I end up with 010 or just 1.

I have tried to use integers but get the same result and have tried == and compare for strings but nothing.

NSString *millieString = [[NSString alloc]initWithFormat:@"%@",timeFieldMillie.text];


if([millieString compare:@"01"]){
timeFieldMillie.text = [[NSString alloc]initWithString:millieString];
}
else if ([millieString compare:@"1"]){
timeFieldMillie.text = [[NSString alloc]initWithFormat:@"%@0", millieString];
}

This is probably because the first 0 is not being read but I can’t seem to fix it.
I am trying to make a time converter and this is for the milliseconds so I need it to be 2 digits long.

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-26T10:06:24+00:00Added an answer on May 26, 2026 at 10:06 am
    • Use -isEqualToString: instead
    • You’re leaking memory
    • The string is reset without the need to do it in your first if

    Here’s a simpler version:

    if ([timeFieldMillie.text isEqualToString:@"1"])
         timeFieldMillie.text = [NSString stringWithString:@"01"];
    

    Or simply:

    if ([timeFieldMillie.text isEqualToString:@"1"])
         timeFieldMillie.text = @"01";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UIDatePicker that only has month, day, and year. I am trying
I´m trying to code a tooltip (Yes I know, I have my reasons to
I am trying to make some small additions to some old java code that
i have been trying to copy text input from alertview textfield to a NSMutableArray
I am trying to create a GUI that allows someone to set up an
I will be very, VERY grateful if someone can help me figure out my
I have a form that im working on, im trying to reset a field
I'm trying to write a Java program that can automatically log into Facebook. I've
I'm working with JTextField and the code for the text field. I'm trying to
I am having an issue converting type. I was trying code like this (minimal,

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.