SHARE
TWEET

Convert a string into an int

a guest Mar 30th, 2012 13 Never
  1. NSString *string = @"5";
  2. int value = [string intValue];
  3.        
  4. NSString *string = /* Assume this exists. */;
  5. int value = [string intValue];
  6.        
  7. [@"7" intValue];
  8.        
  9. [NSNumberFormatter numberFromString:@"7"];
  10.        
  11. NSInteger stringToInt(NSString *string) {
  12.     return [string integerValue];
  13. }
  14.        
  15. NSString* intToString(NSInteger integer) {
  16.     return [NSString stringWithFormat:@"%d", integer];
  17. }
RAW Paste Data
Top