From bf31d12fb62de04bf39ac1c5b670b22ba3e7c9bc Mon Sep 17 00:00:00 2001 From: Patrick Hughes Date: Fri, 8 Mar 2019 17:55:16 -0500 Subject: [PATCH] A fix for https://github.com/danielgindi/Charts/issues/3848. Use a stock iterator instead of a custom one. --- .../BarLineScatterCandleBubbleRenderer.swift | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/Source/Charts/Renderers/BarLineScatterCandleBubbleRenderer.swift b/Source/Charts/Renderers/BarLineScatterCandleBubbleRenderer.swift index 9ae8651a22..7c258b1f41 100644 --- a/Source/Charts/Renderers/BarLineScatterCandleBubbleRenderer.swift +++ b/Source/Charts/Renderers/BarLineScatterCandleBubbleRenderer.swift @@ -102,22 +102,18 @@ extension BarLineScatterCandleBubbleRenderer.XBounds: RangeExpression { extension BarLineScatterCandleBubbleRenderer.XBounds: Sequence { public struct Iterator: IteratorProtocol { - private let bounds: BarLineScatterCandleBubbleRenderer.XBounds - private var value: Int - - fileprivate init(bounds: BarLineScatterCandleBubbleRenderer.XBounds) { - self.bounds = bounds - self.value = bounds.min + private var iterator: IndexingIterator> + + fileprivate init(min: Int, max: Int) { + self.iterator = (min...max).makeIterator() } - + public mutating func next() -> Int? { - guard value < bounds.max else { return nil } - value += 1 - return value + return self.iterator.next() } } - + public func makeIterator() -> Iterator { - return Iterator(bounds: self) + return Iterator(min: self.min, max: self.max) } }