Help with displaying integers

Discussion in 'iPhone/iPad Programming' started by iphonedevelop18, Mar 2, 2009.

  1. macrumors member

    Joined:
    Feb 26, 2009
    #1
    int number = 20;

    NSString *labelText = [[NSString alloc] initWithFormat:mad:"%f", number];
    label.text = labelText;
    [labelText release];

    how would I make the text output the integer, it worked with a slider to output the "slider.value" so now i cant get it to output the integer. I think is has something to do with the @"%f" because when you output a string, you use @"%@d".
     
  2. Guest

    caveman_uk

    Joined:
    Feb 17, 2003
    Location:
    Hitchin, Herts, UK
    #2
    Use %i for integers
     
  3. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #3
    No, you should be using %@ for strings.
     
  4. Guest

    caveman_uk

    Joined:
    Feb 17, 2003
    Location:
    Hitchin, Herts, UK
    #4
    I just assumed the OP was a bad typist and let that one go....:D
     
  5. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #5
    Based on this thread and others started by the OP, I'm afraid it's more than just bad typing. They don't seem to have a good grasp of even the basics of Objective-C. I feel they would be best served if they stepped back and did some reading and learning about the language and its usage.
     
  6. thread starter macrumors member

    Joined:
    Feb 26, 2009
    #6
    Thank you for helping me, sorry for asking so many questions, If you could I would like a website that would help me more understand objective c as I have only programmed in a variation of c for robots and other languages.
     
  7. Guest

    caveman_uk

    Joined:
    Feb 17, 2003
    Location:
    Hitchin, Herts, UK
    #7
    The thing is that the question in this thread and in the other one about maths functions are basic bog-standard C. They're not specific to objective C.
     

Share This Page