Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert NSString to NSInteger?

I want to convert string data to NSInteger.

like image 989
The deals dealer Avatar asked Jan 25 '11 08:01

The deals dealer


2 Answers

If the string is a human readable representation of a number, you can do this:

NSInteger myInt = [myString intValue];
like image 147
Aurum Aquila Avatar answered Oct 17 '22 19:10

Aurum Aquila


[myString intValue] returns a cType "int"

[myString integerValue] returns a NSInteger.

In most cases I do find these simple functions by looking at apples class references, quickest way to get there is click [option] button and double-click on the class declarations (in this case NSString ).

like image 25
EtienneSky Avatar answered Oct 17 '22 21:10

EtienneSky