Want more features on Pastebin? Sign Up, it's FREE!
Guest

Convert a string into an int

By: a guest on Mar 30th, 2012  |  syntax: None  |  size: 0.39 KB  |  views: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. }
clone this paste RAW Paste Data