質問

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">ここを。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top