0
我用一個description
方法重載我的主類的每個子類,但是在它裏面,我該如何使屬性保持縮進?使用\ r不起作用,因爲新項目沒有縮進。iPhone - 我如何獲得NSLog深度輸出自定義類縮進,因爲它爲NSArrays或NSDictionaries?
- (NSString*) description
{
NSMutableString* str = [NSMutableString string];
[str appendFormat:@"One attribute : %d\r", self.oneAttribute];
[str appendFormat:@"List : %@\r", self.myArrayOfCustomObjects];
return str;
}
- (NSString*) description (on custom object)
{
NSMutableString* str = [NSMutableString string];
[str appendFormat:@"One attribute : %d\r", self.oneAttribute];
[str appendFormat:@"One other attribute : %d\r", self.oneOtherAttribute];
return str;
}
怎麼樣自定義類對象的數組? – Oliver 2012-02-29 01:47:17
他們呢?你是說數組不會格式化每個自定義對象,或者根本不能打印數組? – 2012-02-29 12:06:17
\ n不起作用,它只是寫在控制檯上。 – Oliver 2012-02-29 23:03:11