stringByReplacingOccurrencesOfString不起作用

时间:2015-11-26 07:12:09

标签: ios

我想将时间格式更改为1到1,00

代码:

 lblLoggedHoursValue.text = [lblLoggedHoursValue.text stringByReplacingOccurrencesOfString:@"." withString:@","];

1 个答案:

答案 0 :(得分:0)

这里我在浮动中转换你的值然后在替换之后。

lblLoggedHoursValue.text = @"1";
lblLoggedHoursValue.text = [NSString stringWithFormat:@"%.2f",[lblLoggedHoursValue.text floatValue]];

NSLog(@"%@",lblLoggedHoursValue.text); //Output : 1.00

现在将lblLoggedHoursValue.text(。)替换为(,)

lblLoggedHoursValue.text = [lblLoggedHoursValue.text stringByReplacingOccurrencesOfString:@"." withString:@","];

NSLog(@"%@",lblLoggedHoursValue.text); //Output : 1,00