Come faccio a impostare segnaposto char (%)?
-
13-09-2019 - |
Domanda
In Objective-c ... Voglio rappresentare segnaposto char (%) ma il mio codice non lo fanno ....
NSString *base = @"<style type=\"test/css\">div{width:100\%}</style><body>%@</body>";
NSString *html = [NSString stringWithFormat:base, @"hello world"];
NSLog(@"%@",html);
- aspettarsi: div {width: 100%}
- reale: div {width: 100}
ciò che è sbagliato?
Soluzione
Prova questo:
NSString *base = @"<style type=\"test/css\">div{width:100%%}</style><body>%@</body>";
L'elenco completo degli identificatori di formato è qui .
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow