7

Possible Duplicate:
How to do string conversions in Objective-C?

I am trying to convert a user's guess into an integer. How do I do that?

Community
  • 1
  • 1
user457303
  • 157
  • 1
  • 3
  • 9

1 Answers1

22

This is trivial in Objective-C...

NSString *inputString = @"75";
int value = [inputString intValue];

You can also use floatValue, doubleValue or (I believe) even boolValue to convert an NSString to other types. Here is a page that lists some common tasks you may need to perform with strings;

http://borkware.com/quickies/one?topic=NSString

John Wordsworth
  • 2,591
  • 1
  • 20
  • 24