开发者

use '%' in output

开发者 https://www.devze.com 2023-02-03 12:34 出处:网络
Probably a very simple problem and I have been looking for the answer but can not find the it, probably because i have not found out what to ask.

Probably a very simple problem and I have been looking for the answer but can not find the it, probably because i have not found out what to ask.

I want the following output, see the '%' character in the output:

(33%)

i just do not understand how to format in the "%" character so it is seen in the output.

txt2 = [txt2 stringByAppendingFormat:@"(%i)", percentage];

I know that the above stringByAppendin开发者_开发知识库gFormat is wrong. I would very much appreciate any help.


Escape it with another % so you get something like this:

txt2 = [txt2 stringByAppendingFormat:@"(%i%%)", percentage];

For a list of all format specifiers to use with the formatting functions, see here.

0

精彩评论

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

关注公众号