开发者

Some maths questions on Obj-C

开发者 https://www.devze.com 2023-01-23 13:41 出处:网络
I just have two questions on Obj-C. I have a string value: \"234.67\". How can i change the dot to comma? Resulting 234开发者_如何学C,67?

I just have two questions on Obj-C. I have a string value: "234.67". How can i change the dot to comma? Resulting 234开发者_如何学C,67?

Another questions is, how work the split/division on Obj-C? I have a value, 255.45 and i want to divide it twelve times.

Thanks!


To replace the period with a comma, you should replace it in the string when you want to display it.

NSString *str = @"234.67";

str = [str stringByReplacingOccurrencesOfString:@"."
                                     withString:@","];

To divide you just use the operator

float j;

j = 234.67 / 12;

Good Luck.

0

精彩评论

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