How can I include a percent symbol (%) in my NSString?
[NSString stringWithFormat:@"Downloading (%1.0%)", percentage]
The above code does not include the last percent in the string.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Carl is right about the escaping, but it alone won’t work with the code you have given. You are missing a format specifier after the first percentage sign. Given
percentageis a double, try:Note the
%.1f, for formatting a double with one decimal. This gives45.5 %. Use%.ffor no decimals.Also see http://developer.apple.com/library/mac/#documentation/cocoa/conceptual/strings/Articles/formatSpecifiers.html