I already did that, sorry for not providing any code. Take this as an example:
public struct Wrapper<Element> { private var elements: [Element] public init<S: Sequence where S.Iterator.Element == Element>(_ sequence: S) { elements = [Element](sequence) } } extension Wrapper: Collection { public var startIndex: Int { return elements.startIndex } public var endIndex: Int { return elements.endIndex } public func index(after index: Int) -> Int { return index + 1 } public subscript(position: Int) -> Element { return elements[position] } } extension Wrapper: CustomReflectable { public var customMirror: Mirror { return Mirror(self, unlabeledChildren: self, displayStyle: .collection) } } If I debug an instance of this Wrapper type, then Xcode’s Variables View will show ▿ wrapper ▿ elements = x values [0] = 0 [1] = … But the `elements` property is an implementation detail. What I would really want to see is this: ▿ wrapper = x values [0] = 0 [1] = … But I’m not sure if this is even possible. That’s basically why I’m asking this. Hopefully it’s clearer now :) One last thing to note, the code `dump(wrapper)` will print ▿ 3 elements - 1 - 2 - 3 to the console, which is good. If I don’t implement CustomReflectable, then `dump(wrapper)` will show this: ▿ Wrapper<Swift.Int> ▿ elements: 3 elements - 1 - 2 - 3 So my CustomReflectable conformance is definitely doing something, but I would like to see the results in the variables view as well. > On 27 Jun 2016, at 01:40, Dmitri Gribenko <griboz...@gmail.com> wrote: > > On Fri, Jun 24, 2016 at 3:53 PM, Tim Vermeulen via swift-users > <swift-users@swift.org> wrote: >> I’ve implemented a linked list. Now I’d like to be able to view the elements >> of a linked list in the debugger just like with an array. In the debugger, >> an array is represented like this: >> >> [0] = the first element >> [1] = the second element >> etc >> >> I wonder if I can do the same for my linked list. I already implemented >> CustomReflectable, so the code `dump(myLinkedList)` shows this in the >> console: >> >> 3 elements >> - first element >> - second elements >> - third element >> >> I thought this would also change the appearance of my linked list in the >> debugger, but unfortunately it’s unchanged. Is there a way to do what I’m >> trying to do? > > Try setting "displayStyle: .collection" when you call the Mirror initializer. > > Dmitri > > -- > main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if > (j){printf("%d\n",i);}}} /*Dmitri Gribenko <griboz...@gmail.com>*/
_______________________________________________ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users