gpt4 book ai didi

objective-c - NSLog 输出中出现换行符

转载 作者:太空狗 更新时间:2023-10-30 03:45:36 24 4
gpt4 key购买 nike

<分区>

我有以下方法:

- (NSString *)description {
return [NSString stringWithFormat:@"Attribute %@: %@", name, [values description]];
}

Name 是一个字符串,values 是一个 NSArray。我有一个包含其中几个对象的 NSArray。

当我使用 NSLog(@"Attribute created: %@", [newAttribute description]); 打印属性时,它工作正常,并打印如下:

2012-12-08 14:38:06.883 DT[25684:303] Attribute created: Attribute color: (
YELLOW,
PURPLE
)
2012-12-08 14:38:06.884 DT[25684:303] Attribute created: Attribute size: (
LARGE,
SMALL
)

但是,如果我创建一个 NSMutableArray 并在其中放置几个​​属性对象,当我以相同的方式打印数组时,我会得到这个输出:

2012-12-08 14:38:06.887 DT[25684:303] Attributes: (
"Attribute color: (\n YELLOW,\n PURPLE\n)",
"Attribute size: (\n LARGE,\n SMALL\n)",
)

为什么它会在此上下文中打印换行符,我该如何防止它这样做?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com