开发者

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

开发者 https://www.devze.com 2023-01-17 05:54 出处:网络
This question already has answers here: 开发者_运维百科 Closed 10 years ago. Possible Duplicate: How to do string conversions in Objective-C?
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

精彩评论

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