0

How to convert NSString to Integer...

i mean.

NSString *one=@"1";

i want to get this value like this.. int t=1;

is it possible..?

pls help me thanks and regards... by raju

1

2 Answers 2

6

NSString has an intValue (or the preferred "integerValue") method that can be used to parse the string to an int.

It would look something like this:

int i = [myString intValue];

Check out the docs here:

http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/occ/instm/NSString/intValue

2

You can do something like the following:

NSString *one = @"1";
int t = [one intValue];

More discussion here: How to do string conversions in Objective-C?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.