What is the Objective-C equivalent of Java parseInt ()?

m anew comer for iPhone ... before I developed it for Android. Can someone tell me what is the alternative code in the C..Thanx lens in advance

Int projectNumber = Integer.parseInt(projectNumber.trim()); 
+6
objective-c iphone
source share
1 answer
 int intProjectNumber = [[projectNumber stringByTrimmingCharactersInSet:whitespaceCharacterSet] integerValue]; 

edit: Just to explain a little more.

If you have an NSString named projectNumber (for example, @ "4"). You can create a new line with a clipped space infront of the line and after the line with

 NSString *trimedProjectNumber = [projectNumber stringByTrimmingCharactersInSet:whitespaceCharacterSet]; 

as you can see, this replaces the trim () function

trimedProjectNumber will now be @ "4". If you want to get an integer representation of this string:

 int intProjectNumber = [trimedProjectNumber integerValue]; 

it replaces parseInt ..

I don't know java, but I think this is what youre code does? Unless you explain what java code does ..

+8
source share

All Articles