Pregunta

En Objective-C ... quiero representar a su marcador de posición (%) pero mi código no ...

NSString *base = @"<style type=\"test/css\">div{width:100\%}</style><body>%@</body>";
NSString *html = [NSString stringWithFormat:base, @"hello world"];
NSLog(@"%@",html);
  • Espere: Div {ancho: 100%}
  • Real: div {ancho: 100}

¿qué está mal?

¿Fue útil?

Solución

Prueba esto:

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

La lista completa de especificadores de formato es aquí.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top