Convert a string into an int

MacN00b picture MacN00b · Jul 10, 2011 · Viewed 131.1k times · Source

I'm having trouble converting a string into an integer. I googled it but all I can find is how to convert an int into a string. Does anyone know how to do it the other way around? Thanks.

Answer

Espresso picture Espresso · Jul 10, 2011

See the NSString Class Reference.

NSString *string = @"5";
int value = [string intValue];