views:

158

answers:

2

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

+6  A: 

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

Andy White
+2  A: 

You can do something like the following:

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

More discussion here: http://stackoverflow.com/questions/169925/how-to-do-string-conversions-in-objective-c/171486

runako
thanks ... it is working well.
Raju