开发者

How to convert string to float in objective-c

开发者 https://www.devze.com 2023-03-09 16:30 出处:网络
I have string and I want to convert into double value. I have written code but sometimes my program is being crashed.

I have string and I want to convert into double value. I have written code but sometimes my program is being crashed.

double left_operand=[operand_1 doubleValue];

Here operand_1 is NSString v开发者_运维知识库ariable and i want to convert it into double value. Sometimes above code is crashing my program (automatically closed simulator)

Is above code right?


You may be getting this error because operand_1 is not accessible here because probably you are releasing it above this line or if you are using auto release then you are not retaining it, check for it by NSLog(@"%@",operand_1); before the above line if you are getting same error then i m right.


float valueFloat=[*your string* floatValue];
double valueDouble=[*yourstring* doubleValue];
0

精彩评论

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

关注公众号