Wednesday, July 21, 2010

Converting NSString to int, float, double, and bool

Here's another really basic & simple NSString tip for today to help you convert strings to various basic types. The NSString class has a bunch of conversions already built in:

float stringFloat = [myString floatValue];
int stringInt = [myString intValue]
double stringDouble = [myString doubleValue]
BOOL boolValue = [myString boolValue];

2 comments:

  1. nothing happning .........
    update another one .......

    ReplyDelete
  2. very helpful post. searched the net for a straight answer and this was the ONLY concise, to-the-point and meaningful one.

    THANK YOU!

    ReplyDelete