Comment puis-je configurer espace réservé char (%)?
-
13-09-2019 - |
Question
Objective-c ... Je veux représenter l'espace réservé char (%) mais mon code ne le font pas ....
NSString *base = @"<style type=\"test/css\">div{width:100\%}</style><body>%@</body>";
NSString *html = [NSString stringWithFormat:base, @"hello world"];
NSLog(@"%@",html);
- attendre: div {width: 100%}
- real: div {width: 100}
ce qui est faux?
La solution
Essayez ceci:
NSString *base = @"<style type=\"test/css\">div{width:100%%}</style><body>%@</body>";
La liste complète des spécificateurs de format est ici .
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow