int Archives

How to convert an NSString into an integer

Imagine you had an NSString and wanted to save it as an integer value. You can use the intValue method for that: NSString *myString = @”47″; int myInt = [myString intValue]; To do the reverse, you can use the initWithFormat method: int myInt = 32; NSString *myOtherString = [[NSString alloc]initWithFormat:@”%i”, myInt];