Skip to content

Commit

Permalink
Fix 'flatMap' is deprecated warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
kellyroach committed Jul 12, 2018
1 parent f9e76ab commit 8ae8788
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Examples/Examples/MultiTrackerExample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class MultiTrackerExample: UIViewController, UIGestureRecognizerDelegate {
circles
]

return Chart(frame: frame, innerFrame: coordsSpace.chartInnerFrame, settings: chartSettings, layers: layers.flatMap { $0 })
return Chart(frame: frame, innerFrame: coordsSpace.chartInnerFrame, settings: chartSettings, layers: layers.compactMap { $0 })
}

private func generateIOBChartWithFrame(frame: CGRect) -> Chart? {
Expand Down Expand Up @@ -273,7 +273,7 @@ class MultiTrackerExample: UIViewController, UIGestureRecognizerDelegate {
IOBLine,
]

return Chart(frame: frame, innerFrame: coordsSpace.chartInnerFrame, settings: chartSettings, layers: layers.flatMap { $0 })
return Chart(frame: frame, innerFrame: coordsSpace.chartInnerFrame, settings: chartSettings, layers: layers.compactMap { $0 })
}
}

Expand Down
4 changes: 2 additions & 2 deletions SwiftCharts/Axis/ChartAxisXLayerDefault.swift
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class ChartAxisXLayerDefault: ChartAxisLayerDefault {
let scalars = valuesGenerator.generate(axis)

currentAxisValues = scalars
return scalars.flatMap {scalar in
return scalars.compactMap {scalar in

let labels = labelsGenerator.generate(scalar, axis: axis)

Expand Down Expand Up @@ -185,7 +185,7 @@ class ChartAxisXLayerDefault: ChartAxisLayerDefault {
// Get max text height for each row of axis values
fileprivate func rowHeightsForRows(_ rows: [[ChartAxisLabel?]]) -> [CGFloat] {
return rows.map { row in
row.flatMap { $0 }.reduce(-1) { maxHeight, label in
row.compactMap { $0 }.reduce(-1) { maxHeight, label in
return max(maxHeight, label.textSize.height)
}
}
Expand Down
2 changes: 1 addition & 1 deletion SwiftCharts/ChartAxisValueArray.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import UIKit
extension Array where Element: ChartAxisValue {

func calculateLabelsDimensions() -> (total: CGSize, max: CGSize) {
return flatMap({
return compactMap({
guard let label = $0.labels.first else {return nil}
return label.textSizeNonRotated
}).reduce((total: CGSize.zero, max: CGSize.zero), {(lhs: (total: CGSize, max: CGSize), rhs: CGSize) in
Expand Down
2 changes: 1 addition & 1 deletion SwiftCharts/Layers/ChartPointsViewsLayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ open class ChartPointsViewsLayer<T: ChartPoint, U: UIView>: ChartPointsLayer<T>
}

fileprivate func generateChartPointViews(chartPointModels: [ChartPointLayerModel<T>], chart: Chart) -> [ViewWithChartPoint] {
let viewsWithChartPoints: [ViewWithChartPoint] = chartPointsModels.flatMap {model in
let viewsWithChartPoints: [ViewWithChartPoint] = chartPointsModels.compactMap {model in
if let view = viewGenerator(model, self, chart) {
return (view: view, chartPointModel: model)
} else {
Expand Down

0 comments on commit 8ae8788

Please sign in to comment.