Ответ 1
Я раскалываю немного больше в iOS-структурах, и я заметил, что поведение по умолчанию для описания iOS sdk заключается не в том, чтобы поместить "\n", но ";".
Пример:
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]);
Вывод:
FontDescription: font-family: "Helvetica"; font-weight: normal; font-style: 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"
)
Итак, я решил использовать тот же подход с моим классом.
- (NSString *)description {
NSString *descriptionString = [NSString stringWithFormat:@"Name: %@; Address: %@;", self.name, self.address];
return descriptionString;
}
И выход будет:
"Имя: Alex; Адрес: какой-то адрес;
Для объекта он сам.
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;"
)
Для массива объектов.