开发者

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

m anew comer to iPhone...before i have developed for Andr开发者_如何学Gooid..Could any one tell me what is the alternate code in objective C..Thanx in advance

Int projectNumber = Integer.parseInt(projectNumber.trim());


int intProjectNumber = [[projectNumber stringByTrimmingCharactersInSet:whitespaceCharacterSet] integerValue];

edit: Just to explain a bit more..

If you have a NSString named projectNumber (ie. @" 4 "). You can make a new string with trimed whitespace infront of the string and after the string with

NSString *trimedProjectNumber = [projectNumber stringByTrimmingCharactersInSet:whitespaceCharacterSet];

as you can see this replaces the trim() function

trimedProjectNumber would now be @"4". If you want an integer representation of this string you do:

int intProjectNumber = [trimedProjectNumber integerValue];

this replaces the parseInt..

I dont know java but i think this is what youre code does? If not explain what the java code does..

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜