开发者

How do I convert a string into an integer in objective C? [duplicate]

This question already has answers here: 开发者_运维百科 Closed 10 years ago.

Possible Duplicate:

How to do string conversions in Objective-C?

I am trying to convert a user's guess into an integer. How do I do that?


This is trivial in Objective-C...

NSString *inputString = @"75";
int value = [inputString intValue];

You can also use floatValue, doubleValue or (I believe) even boolValue to convert an NSString to other types. Here is a page that lists some common tasks you may need to perform with strings;

http://borkware.com/quickies/one?topic=NSString

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜