Converting Strings.

Discussion in 'Mac Programming' started by Rhalliwell1, Sep 6, 2009.

  1. Rhalliwell1 macrumors 6502a

    Joined:
    May 22, 2008
    #1
    Hi,

    I am just starting to learn objective-c and can't find a way to convert from a String to a float (or any other variable type.)
    Could anyone give me a point in the right direction?

    Cheers :)
     
  2. Eraserhead macrumors G4

    Eraserhead

    Joined:
    Nov 3, 2005
    Location:
    UK
    #2
    To convert a string to a float:

    Code:
    NSString *str = @"10.0";
    float f = [str floatValue];
    NSLog(@"float = %lf", f);
     
  3. Rhalliwell1 thread starter macrumors 6502a

    Joined:
    May 22, 2008

Share This Page