Excavo un poco más en los marcos de iOS y he observado que el comportamiento predeterminado de la descripción sdk de iOS no es colocar "\ n" sino ";".
Ejemplo:
UIFont *font = [UIFont systemFontOfSize:18];
NSLog(@"FontDescription:%@",[font description]);
NSMutableArray *fontsArray = [NSMutableArray arrayWithCapacity:0];
for(int index = 0; index < 10; index++) {
[fontsArray addObject:font];
}
NSLog(@"FontsArrayDescription:%@",[fontsArray description]);
El apagada es:
FontDescription: font-family: "Helvetica"; font-weight: normal; estilo de fuente: normal; font-size: 18px
FontsArrayDescription :(
"<UICFFont: 0x6e2d8b0> font-family: \"Helvetica\"; font-weight: normal; font-style: normal; font-size: 18px",
"<UICFFont: 0x6e2d8b0> font-family: \"Helvetica\"; font-weight: normal; font-style: normal; font-size: 18px",
"<UICFFont: 0x6e2d8b0> font-family: \"Helvetica\"; font-weight: normal; font-style: normal; font-size: 18px",
"<UICFFont: 0x6e2d8b0> font-family: \"Helvetica\"; font-weight: normal; font-style: normal; font-size: 18px",
"<UICFFont: 0x6e2d8b0> font-family: \"Helvetica\"; font-weight: normal; font-style: normal; font-size: 18px",
"<UICFFont: 0x6e2d8b0> font-family: \"Helvetica\"; font-weight: normal; font-style: normal; font-size: 18px",
"<UICFFont: 0x6e2d8b0> font-family: \"Helvetica\"; font-weight: normal; font-style: normal; font-size: 18px",
"<UICFFont: 0x6e2d8b0> font-family: \"Helvetica\"; font-weight: normal; font-style: normal; font-size: 18px",
"<UICFFont: 0x6e2d8b0> font-family: \"Helvetica\"; font-weight: normal; font-style: normal; font-size: 18px",
"<UICFFont: 0x6e2d8b0> font-family: \"Helvetica\"; font-weight: normal; font-style: normal; font-size: 18px"
)
Así que han decidido utilizar el mismo enfoque con mi clase.
- (NSString *)description {
NSString *descriptionString = [NSString stringWithFormat:@"Name: %@; Address: %@;", self.name, self.address];
return descriptionString;
}
Y la opción de venta a cabo será:
"Nombre: Alex; Dirección: alguna dirección;"
Para el objeto en sí.
objecsArrayDescription :(
"Name:Alex; Address: some address;",
"Name:Alex; Address: some address;",
"Name:Alex; Address: some address;",
"Name:Alex; Address: some address;",
"Name:Alex; Address: some address;",
"Name:Alex; Address: some address;",
"Name:Alex; Address: some address;",
"Name:Alex; Address: some address;",
"Name:Alex; Address: some address;",
"Name:Alex; Address: some address;"
)
Para una matriz de objetos.
tendrá que bucle sobre los elementos y llamar 'description' en cada uno. La descripción del array está formateada, lo que puede provocar un cortocircuito en algunas cosas como "\ n", para mantener el formato coherente. –
ver [http://stackoverflow.com/a/1828689/971401](http://stackoverflow.com/a/1828689/971401). Las respuestas probablemente te pueden ayudar. –