プレースホルダー文字(%)を設定するにはどうすればよいですか?
-
13-09-2019 - |
質問
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%}
- 本物 :div{幅:100}
なにが問題ですか?
解決
これを試してください:
NSString *base = @"<style type=\"test/css\">div{width:100%%}</style><body>%@</body>";
書式指定子の完全なリストは、<のhref = "http://developer.apple.com/mac/library/documentation/cocoa/Conceptual/Strings/Articles/formatSpecifiers.html#//apple_ref/doc/uidです/ TP40004265" のrel = "nofollowをnoreferrer">ここを。
所属していません StackOverflow