문제

Objective-C에서 ... 나는 자리 표시 자 char (%)를 대표하고 싶지만 내 코드는 그렇지 않습니다 ....

NSString *base = @"<style type=\"test/css\">div{width:100\%}</style><body>%@</body>";
NSString *html = [NSString stringWithFormat:base, @"hello world"];
NSLog(@"%@",html);
  • 기대 : div {너비 : 100%}
  • Real : div {너비 : 100}

뭐가 잘못 되었 니?

도움이 되었습니까?

해결책

이 시도:

NSString *base = @"<style type=\"test/css\">div{width:100%%}</style><body>%@</body>";

형식 지정자의 전체 목록은 다음과 같습니다 여기.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top