I thought the Printable
protocol would do it, but it doesn't. Is there another protocol? I want it to show the 3 numbers, not "C._GLKVector3"
Asked
Active
Viewed 197 times
4

Rob N
- 15,024
- 17
- 92
- 165
-
There's a `DebugPrintable` protocol. Perhaps try that? – nhgrif Apr 27 '15 at 00:11
-
I just tried. That's not it. – Rob N Apr 27 '15 at 00:16
-
Your right. I just tried it as well. – nhgrif Apr 27 '15 at 00:19
2 Answers
2
As of Swift 2 this can be done by making the type conform to CustomStringConvertible
(previously Printable
). In the case of GLKVector3
you would do:
extension GLKVector3: CustomStringConvertible {
public var description: String {
return "<\(x), \(y), \(z)>"
}
}

ABakerSmith
- 22,759
- 9
- 68
- 78
0
Try import XCPlayground there is something for that. Here is everything from that modul: https://developer.apple.com/library/mac/documentation/Swift/Reference/Playground_Ref/Chapters/XCPlayground.html

Jan Kaifer
- 664
- 4
- 18