我认为Printable
协议会这样做,但事实并非如此。还有其他协议吗?我希望它显示3个数字,而不是“C._GLKVector3”
答案 0 :(得分:2)
从Swift 2开始,这可以通过使类型符合CustomStringConvertible
(以前为Printable
)来完成。在GLKVector3
的情况下,你会这样做:
extension GLKVector3: CustomStringConvertible {
public var description: String {
return "<\(x), \(y), \(z)>"
}
}
答案 1 :(得分:0)
尝试导入XCPlayground有一些东西。 以下是该模块的所有内容:https://developer.apple.com/library/mac/documentation/Swift/Reference/Playground_Ref/Chapters/XCPlayground.html