gpt4 book ai didi

swift - 在 Xcode Playground 中,控制右侧栏中的字符串表示?

转载 作者:搜寻专家 更新时间:2023-10-31 19:35:12 25 4
gpt4 key购买 nike

我认为 Printable 协议(protocol)可以做到这一点,但事实并非如此。还有其他协议(protocol)吗?我希望它显示 3 个数字,而不是“C._GLKVector3”

enter image description here

最佳答案

从 Swift 2 开始,这可以通过使类型符合 CustomStringConvertible(以前是 Printable)来完成。在 GLKVector3 的情况下,你会这样做:

extension GLKVector3: CustomStringConvertible {
public var description: String {
return "<\(x), \(y), \(z)>"
}
}

enter image description here

关于swift - 在 Xcode Playground 中,控制右侧栏中的字符串表示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29885188/

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