[swift-users] Custom Reflectable

Dylan Wreggelsworth dylan at bvrgroup.us
Wed Jan 25 10:41:31 CST 2017


Greetings all,
I'd like to put together an extension for CGVector that allows it to be
seen much like CGPoint i.e.:  { dx: 1.0, dy: 1.0 } instead of { x: 1.0, y:
1.0 }. However, when I use:

// This seems broken, ```.`struct```` doesn't work at all...
extension CGVector: CustomReflectable {
    public var customMirror: Mirror {
        return Mirror(self, children: ["dx": dx, "dy": dy], displayStyle:
.struct)
    }
}

What I get is " __C.CGVector". Now, If I change displayStyle to .tuple, I
get values formatted like a tuple.

Am I not fully adhering to CustomReflectable? Is this a C bridging issue?
Or is this a flaw?

Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170125/96cbdb6c/attachment.html>


More information about the swift-users mailing list