0

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,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!

Lucas Veiga
  • 1,758
  • 7
  • 27
  • 45
  • http://stackoverflow.com/questions/668228/string-replacement-in-objective-c – Naveed Nov 01 '10 at 17:09
  • Can't understand this: "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." ... what do you mean by divide twelve times and what would this have to do with splitting? – Peer Stritzinger Nov 01 '10 at 17:10

1 Answers1

3

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.

Chris Lucian
  • 1,013
  • 6
  • 15