Skip to content

Commit

Permalink
Fixed copyWithZone for latest Swift 2.0 changes (Fixes #410)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgindi committed Oct 1, 2015
1 parent 062a61b commit d6cb47e
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 7 deletions.
5 changes: 5 additions & 0 deletions Charts/Classes/Data/BarChartDataEntry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ public class BarChartDataEntry: ChartDataEntry
/// the sum of all positive values this entry (if stacked) contains
private var _positiveSum: Double = 0.0

public required init()
{
super.init()
}

/// Constructor for stacked bar entries.
public init(values: [Double], xIndex: Int)
{
Expand Down
5 changes: 5 additions & 0 deletions Charts/Classes/Data/BarChartDataSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ public class BarChartDataSet: BarLineScatterCandleBubbleChartDataSet
/// array of labels used to describe the different values of the stacked bars
public var stackLabels: [String] = ["Stack"]

public required init()
{
super.init()
}

public override init(yVals: [ChartDataEntry]?, label: String?)
{
super.init(yVals: yVals, label: label)
Expand Down
5 changes: 5 additions & 0 deletions Charts/Classes/Data/BubbleChartDataEntry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ public class BubbleChartDataEntry: ChartDataEntry
/// The size of the bubble.
public var size = CGFloat(0.0)

public required init()
{
super.init()
}

/// - parameter xIndex: The index on the x-axis.
/// - parameter val: The value on the y-axis.
/// - parameter size: The size of the bubble.
Expand Down
5 changes: 5 additions & 0 deletions Charts/Classes/Data/CandleChartDataEntry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ public class CandleChartDataEntry: ChartDataEntry
/// open value
public var open = Double(0.0)

public required init()
{
super.init()
}

public init(xIndex: Int, shadowH: Double, shadowL: Double, open: Double, close: Double)
{
super.init(value: (shadowH + shadowL) / 2.0, xIndex: xIndex)
Expand Down
5 changes: 5 additions & 0 deletions Charts/Classes/Data/CandleChartDataSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ public class CandleChartDataSet: LineScatterCandleChartDataSet
/// Are increasing values drawn as filled?
public var increasingFilled = true

public required init()
{
super.init()
}

public override init(yVals: [ChartDataEntry]?, label: String?)
{
super.init(yVals: yVals, label: label)
Expand Down
10 changes: 8 additions & 2 deletions Charts/Classes/Data/ChartDataEntry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class ChartDataEntry: NSObject
/// optional spot for additional data this Entry represents
public var data: AnyObject?

public override init()
public override required init()
{
super.init()
}
Expand Down Expand Up @@ -90,7 +90,13 @@ public class ChartDataEntry: NSObject

public func copyWithZone(zone: NSZone) -> AnyObject
{
return ChartDataEntry(value: value, xIndex: xIndex, data: data)
let copy = self.dynamicType.init()

copy.value = value
copy.xIndex = xIndex
copy.data = data

return copy
}
}

Expand Down
6 changes: 4 additions & 2 deletions Charts/Classes/Data/ChartDataSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class ChartDataSet: NSObject
/// - returns: true if value highlighting is enabled for this dataset
public var isHighlightEnabled: Bool { return highlightEnabled }

public override init()
public override required init()
{
super.init()
}
Expand Down Expand Up @@ -532,7 +532,8 @@ public class ChartDataSet: NSObject

public func copyWithZone(zone: NSZone) -> AnyObject
{
let copy = ChartDataSet()
let copy = self.dynamicType.init()

copy.colors = colors
copy._yVals = _yVals
copy._yMax = _yMax
Expand All @@ -541,6 +542,7 @@ public class ChartDataSet: NSObject
copy._lastStart = _lastStart
copy._lastEnd = _lastEnd
copy.label = label

return copy
}
}
Expand Down
2 changes: 1 addition & 1 deletion Charts/Classes/Data/LineChartDataSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class LineChartDataSet: LineRadarChartDataSet

public var drawCircleHoleEnabled = true

public override init()
public required init()
{
super.init()
circleColors.append(UIColor(red: 140.0/255.0, green: 234.0/255.0, blue: 255.0/255.0, alpha: 1.0))
Expand Down
2 changes: 1 addition & 1 deletion Charts/Classes/Data/PieChartDataSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class PieChartDataSet: ChartDataSet
/// indicates the selection distance of a pie slice
public var selectionShift = CGFloat(18.0)

public override init()
public required init()
{
super.init()

Expand Down
2 changes: 1 addition & 1 deletion Charts/Classes/Data/RadarChartDataSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import UIKit

public class RadarChartDataSet: LineRadarChartDataSet
{
public override init()
public required init()
{
super.init()

Expand Down

0 comments on commit d6cb47e

Please sign in to comment.