2009-12-07 139 views
0

在Objective-C ... 我想代表佔位符字符(%) ,但我的代碼不....我如何設置佔位符字符(%)?

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 {width:100}

有什麼不對?

回答

4

試試這個:

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

格式說明符的完整列表here