Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swift 4 Support #9

Merged
merged 2 commits into from
Oct 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.2
4.0
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github "danielgindi/Charts" == 3.0.3
github "danielgindi/Charts" == 3.0.4
github "realm/realm-cocoa" ~> 2.10
4 changes: 2 additions & 2 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github "danielgindi/Charts" "v3.0.3"
github "realm/realm-cocoa" "v2.10.1"
github "danielgindi/Charts" "v3.0.4"
github "realm/realm-cocoa" "v2.10.2"
4 changes: 2 additions & 2 deletions ChartsRealm.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "ChartsRealm"
s.version = "3.0.3"
s.version = "3.0.4"
s.summary = "A Realm.io module for Charts"
s.homepage = "https://github.com/danielgindi/ChartsRealm"
s.license = { :type => "Apache License, Version 2.0", :file => "LICENSE" }
Expand All @@ -10,6 +10,6 @@ Pod::Spec.new do |s|
s.osx.deployment_target = "10.11"
s.source = { :git => "https://github.com/danielgindi/ChartsRealm.git", :tag => "v#{s.version}" }
s.source_files = "ChartsRealm/Classes/**/*.swift"
s.dependency "Charts", "3.0.3"
s.dependency "Charts", "3.0.4"
s.dependency "RealmSwift", "~> 2.10"
Copy link
Collaborator

@liuxuan30 liuxuan30 Oct 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we bump to 2.10.2 as well though it should be fine?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. We should leave it. All versions of 2.10 should be API compatible.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure. good to go then

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

making sure everything still builds and the pod validates then ill merge

Copy link
Collaborator

@liuxuan30 liuxuan30 Oct 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure. good to go then. My carthage update always timeout after a long time downloading realm swift :(

Copy link
Collaborator Author

@pmairoldi pmairoldi Oct 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use the build command when testing. It's carthage build --no-skip-current. Just builds stuff from checkout.

end
3 changes: 3 additions & 0 deletions ChartsRealm.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@
TargetAttributes = {
06B120D41D811E6200D14B02 = {
CreatedOnToolsVersion = 7.3.1;
LastSwiftMigration = 0900;
};
};
};
Expand Down Expand Up @@ -360,6 +361,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.dcg.ChartsRealm;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -380,6 +382,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.dcg.ChartsRealm;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand Down
18 changes: 9 additions & 9 deletions ChartsRealm/Classes/Data/RealmBarDataSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ open class RealmBarDataSet: RealmBarLineScatterCandleBubbleDataSet, IBarChartDat
super.init(results: results, xValueField: xValueField, yValueField: yValueField, label: label)
}

public init(results: RLMResults<RLMObject>?, xValueField: String?, yValueField: String, stackValueField: String, label: String?)
@objc public init(results: RLMResults<RLMObject>?, xValueField: String?, yValueField: String, stackValueField: String, label: String?)
{
_stackValueField = stackValueField

Expand All @@ -52,7 +52,7 @@ open class RealmBarDataSet: RealmBarLineScatterCandleBubbleDataSet, IBarChartDat
self.init(results: converted, xValueField: xValueField, yValueField: yValueField, stackValueField: stackValueField, label: label)
}

public convenience init(results: RLMResults<RLMObject>?, xValueField: String?, yValueField: String, stackValueField: String)
@objc public convenience init(results: RLMResults<RLMObject>?, xValueField: String?, yValueField: String, stackValueField: String)
{
self.init(results: results, xValueField: xValueField, yValueField: yValueField, stackValueField: stackValueField, label: "DataSet")
}
Expand All @@ -69,7 +69,7 @@ open class RealmBarDataSet: RealmBarLineScatterCandleBubbleDataSet, IBarChartDat
self.init(results: converted, xValueField: xValueField, yValueField: yValueField, stackValueField: stackValueField, label: "DataSet")
}

public convenience init(results: RLMResults<RLMObject>?, yValueField: String, stackValueField: String, label: String)
@objc public convenience init(results: RLMResults<RLMObject>?, yValueField: String, stackValueField: String, label: String)
{
self.init(results: results, xValueField: nil, yValueField: yValueField, stackValueField: stackValueField, label: label)
}
Expand All @@ -86,7 +86,7 @@ open class RealmBarDataSet: RealmBarLineScatterCandleBubbleDataSet, IBarChartDat
self.init(results: converted, yValueField: yValueField, stackValueField: stackValueField, label: label)
}

public convenience init(results: RLMResults<RLMObject>?, yValueField: String, stackValueField: String)
@objc public convenience init(results: RLMResults<RLMObject>?, yValueField: String, stackValueField: String)
{
self.init(results: results, xValueField: nil, yValueField: yValueField, stackValueField: stackValueField)
}
Expand All @@ -108,7 +108,7 @@ open class RealmBarDataSet: RealmBarLineScatterCandleBubbleDataSet, IBarChartDat
super.init(realm: realm, modelName: modelName, resultsWhere: resultsWhere, xValueField: xValueField, yValueField: yValueField, label: label)
}

public init(realm: RLMRealm?, modelName: String, resultsWhere: String, xValueField: String?, yValueField: String, stackValueField: String, label: String?)
@objc public init(realm: RLMRealm?, modelName: String, resultsWhere: String, xValueField: String?, yValueField: String, stackValueField: String, label: String?)
{
_stackValueField = stackValueField

Expand All @@ -127,7 +127,7 @@ open class RealmBarDataSet: RealmBarLineScatterCandleBubbleDataSet, IBarChartDat
self.init(realm: converted, modelName: modelName, resultsWhere: resultsWhere, xValueField: xValueField, yValueField: yValueField, label: label)
}

public convenience init(realm: RLMRealm?, modelName: String, resultsWhere: String, xValueField: String?, yValueField: String, stackValueField: String)
@objc public convenience init(realm: RLMRealm?, modelName: String, resultsWhere: String, xValueField: String?, yValueField: String, stackValueField: String)
{
self.init(realm: realm, modelName: modelName, resultsWhere: resultsWhere, xValueField: nil, yValueField: yValueField, stackValueField: stackValueField)
}
Expand All @@ -144,7 +144,7 @@ open class RealmBarDataSet: RealmBarLineScatterCandleBubbleDataSet, IBarChartDat
self.init(realm: converted, modelName: modelName, resultsWhere: resultsWhere, xValueField: nil, yValueField: yValueField, stackValueField: stackValueField)
}

public convenience init(realm: RLMRealm?, modelName: String, resultsWhere: String, yValueField: String, stackValueField: String, label: String?)
@objc public convenience init(realm: RLMRealm?, modelName: String, resultsWhere: String, yValueField: String, stackValueField: String, label: String?)
{
self.init(realm: realm, modelName: modelName, resultsWhere: resultsWhere, xValueField: nil, yValueField: yValueField, stackValueField: stackValueField, label: label)
}
Expand All @@ -161,7 +161,7 @@ open class RealmBarDataSet: RealmBarLineScatterCandleBubbleDataSet, IBarChartDat
self.init(realm: converted, modelName: modelName, resultsWhere: resultsWhere, xValueField: nil, yValueField: yValueField, stackValueField: stackValueField, label: label)
}

public convenience init(realm: RLMRealm?, modelName: String, resultsWhere: String, yValueField: String, stackValueField: String)
@objc public convenience init(realm: RLMRealm?, modelName: String, resultsWhere: String, yValueField: String, stackValueField: String)
{
self.init(realm: realm, modelName: modelName, resultsWhere: resultsWhere, xValueField: nil, yValueField: yValueField, stackValueField: stackValueField, label: nil)
}
Expand All @@ -186,7 +186,7 @@ open class RealmBarDataSet: RealmBarLineScatterCandleBubbleDataSet, IBarChartDat

// MARK: - Data functions and accessors

internal var _stackValueField: String?
@objc internal var _stackValueField: String?

/// the maximum number of bars that are stacked upon each other, this value
/// is calculated from the Entries that are added to the DataSet
Expand Down
46 changes: 23 additions & 23 deletions ChartsRealm/Classes/Data/RealmBaseDataSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import Realm.Dynamic

open class RealmBaseDataSet: ChartBaseDataSet
{
open func initialize()
@objc open func initialize()
{
fatalError("RealmBaseDataSet is an abstract class, you must inherit from it. Also please do not call super.initialize().")
}
Expand All @@ -44,7 +44,7 @@ open class RealmBaseDataSet: ChartBaseDataSet
initialize()
}

public init(results: RLMResults<RLMObject>?, xValueField: String?, yValueField: String, label: String?)
@objc public init(results: RLMResults<RLMObject>?, xValueField: String?, yValueField: String, label: String?)
{
super.init()

Expand Down Expand Up @@ -79,7 +79,7 @@ open class RealmBaseDataSet: ChartBaseDataSet
self.init(results: converted, xValueField: xValueField, yValueField: yValueField, label: label)
}

public convenience init(results: RLMResults<RLMObject>?, yValueField: String, label: String?)
@objc public convenience init(results: RLMResults<RLMObject>?, yValueField: String, label: String?)
{
self.init(results: results, xValueField: nil, yValueField: yValueField, label: label)
}
Expand All @@ -96,7 +96,7 @@ open class RealmBaseDataSet: ChartBaseDataSet
self.init(results: converted, yValueField: yValueField, label: label)
}

public convenience init(results: RLMResults<RLMObject>?, xValueField: String?, yValueField: String)
@objc public convenience init(results: RLMResults<RLMObject>?, xValueField: String?, yValueField: String)
{
self.init(results: results, xValueField: xValueField, yValueField: yValueField, label: "DataSet")
}
Expand All @@ -113,7 +113,7 @@ open class RealmBaseDataSet: ChartBaseDataSet
self.init(results: converted, xValueField: xValueField, yValueField: yValueField)
}

public convenience init(results: RLMResults<RLMObject>?, yValueField: String)
@objc public convenience init(results: RLMResults<RLMObject>?, yValueField: String)
{
self.init(results: results, yValueField: yValueField)
}
Expand All @@ -130,7 +130,7 @@ open class RealmBaseDataSet: ChartBaseDataSet
self.init(results: converted, yValueField: yValueField)
}

public init(realm: RLMRealm?, modelName: String, resultsWhere: String, xValueField: String?, yValueField: String, label: String?)
@objc public init(realm: RLMRealm?, modelName: String, resultsWhere: String, xValueField: String?, yValueField: String, label: String?)
{
super.init()

Expand Down Expand Up @@ -162,7 +162,7 @@ open class RealmBaseDataSet: ChartBaseDataSet
self.init(realm: converted, modelName: modelName, resultsWhere: resultsWhere, xValueField: xValueField, yValueField: yValueField, label: label)
}

public convenience init(realm: RLMRealm?, modelName: String, resultsWhere: String, yValueField: String, label: String?)
@objc public convenience init(realm: RLMRealm?, modelName: String, resultsWhere: String, yValueField: String, label: String?)
{
self.init(realm: realm, modelName: modelName, resultsWhere: resultsWhere, xValueField: nil, yValueField: yValueField, label: label)
}
Expand All @@ -179,12 +179,12 @@ open class RealmBaseDataSet: ChartBaseDataSet
self.init(realm: converted, modelName: modelName, resultsWhere: resultsWhere, yValueField: yValueField, label: label)
}

open func loadResults(realm: RLMRealm, modelName: String)
@objc open func loadResults(realm: RLMRealm, modelName: String)
{
loadResults(realm: realm, modelName: modelName, predicate: nil)
}

open func loadResults(realm: RLMRealm, modelName: String, predicate: NSPredicate?)
@objc open func loadResults(realm: RLMRealm, modelName: String, predicate: NSPredicate?)
{
if predicate == nil
{
Expand Down Expand Up @@ -217,19 +217,19 @@ open class RealmBaseDataSet: ChartBaseDataSet

// MARK: - Data functions and accessors

internal var _results: RLMResults<RLMObject>?
internal var _yValueField: String?
internal var _xValueField: String?
internal var _cache = [ChartDataEntry]()
@objc internal var _results: RLMResults<RLMObject>?
@objc internal var _yValueField: String?
@objc internal var _xValueField: String?
@objc internal var _cache = [ChartDataEntry]()

internal var _yMax: Double = -Double.greatestFiniteMagnitude
internal var _yMin: Double = Double.greatestFiniteMagnitude
@objc internal var _yMax: Double = -Double.greatestFiniteMagnitude
@objc internal var _yMin: Double = Double.greatestFiniteMagnitude

internal var _xMax: Double = -Double.greatestFiniteMagnitude
internal var _xMin: Double = Double.greatestFiniteMagnitude
@objc internal var _xMax: Double = -Double.greatestFiniteMagnitude
@objc internal var _xMin: Double = Double.greatestFiniteMagnitude

/// Makes sure that the cache is populated for the specified range
internal func buildCache()
@objc internal func buildCache()
{
guard let results = _results else { return }

Expand All @@ -246,15 +246,15 @@ open class RealmBaseDataSet: ChartBaseDataSet
}
}

internal func buildEntryFromResultObject(_ object: RLMObject, x: Double) -> ChartDataEntry
@objc internal func buildEntryFromResultObject(_ object: RLMObject, x: Double) -> ChartDataEntry
{
let entry = ChartDataEntry(x: _xValueField == nil ? x : object[_xValueField!] as! Double, y: object[_yValueField!] as! Double)

return entry
}

/// Makes sure that the cache is populated for the specified range
internal func clearCache()
@objc internal func clearCache()
{
_cache.removeAll()
}
Expand Down Expand Up @@ -287,7 +287,7 @@ open class RealmBaseDataSet: ChartBaseDataSet
/// Updates the min and max x and y value of this DataSet based on the given Entry.
///
/// - parameter e:
internal func calcMinMax(entry e: ChartDataEntry)
@objc internal func calcMinMax(entry e: ChartDataEntry)
{
if e.y < _yMin
{
Expand Down Expand Up @@ -606,7 +606,7 @@ open class RealmBaseDataSet: ChartBaseDataSet
}

/// - returns: The fieldname that represents the "y-values" in the realm-data.
open var yValueField: String?
@objc open var yValueField: String?
{
get
{
Expand All @@ -615,7 +615,7 @@ open class RealmBaseDataSet: ChartBaseDataSet
}

/// - returns: The fieldname that represents the "x-values" in the realm-data.
open var xValueField: String?
@objc open var xValueField: String?
{
get
{
Expand Down
12 changes: 6 additions & 6 deletions ChartsRealm/Classes/Data/RealmBubbleDataSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ open class RealmBubbleDataSet: RealmBarLineScatterCandleBubbleDataSet, IBubbleCh
super.init()
}

public init(results: RLMResults<RLMObject>?, xValueField: String, yValueField: String, sizeField: String, label: String?)
@objc public init(results: RLMResults<RLMObject>?, xValueField: String, yValueField: String, sizeField: String, label: String?)
{
_sizeField = sizeField

Expand All @@ -46,7 +46,7 @@ open class RealmBubbleDataSet: RealmBarLineScatterCandleBubbleDataSet, IBubbleCh
self.init(results: converted, xValueField: xValueField, yValueField: yValueField, sizeField: sizeField, label: label)
}

public convenience init(results: RLMResults<RLMObject>?, xValueField: String, yValueField: String, sizeField: String)
@objc public convenience init(results: RLMResults<RLMObject>?, xValueField: String, yValueField: String, sizeField: String)
{
self.init(results: results, xValueField: xValueField, yValueField: yValueField, sizeField: sizeField, label: "DataSet")
}
Expand All @@ -63,7 +63,7 @@ open class RealmBubbleDataSet: RealmBarLineScatterCandleBubbleDataSet, IBubbleCh
self.init(results: converted, xValueField: xValueField, yValueField: yValueField, sizeField: sizeField)
}

public init(realm: RLMRealm?, modelName: String, resultsWhere: String, xValueField: String, yValueField: String, sizeField: String, label: String?)
@objc public init(realm: RLMRealm?, modelName: String, resultsWhere: String, xValueField: String, yValueField: String, sizeField: String, label: String?)
{
_sizeField = sizeField

Expand All @@ -84,12 +84,12 @@ open class RealmBubbleDataSet: RealmBarLineScatterCandleBubbleDataSet, IBubbleCh

// MARK: - Data functions and accessors

internal var _sizeField: String?
@objc internal var _sizeField: String?

internal var _maxSize = CGFloat(0.0)
@objc internal var _maxSize = CGFloat(0.0)

open var maxSize: CGFloat { return _maxSize }
open var normalizeSizeEnabled: Bool = true
@objc open var normalizeSizeEnabled: Bool = true
open var isNormalizeSizeEnabled: Bool { return normalizeSizeEnabled }

internal override func buildEntryFromResultObject(_ object: RLMObject, x: Double) -> ChartDataEntry
Expand Down
14 changes: 7 additions & 7 deletions ChartsRealm/Classes/Data/RealmCandleDataSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ open class RealmCandleDataSet: RealmLineScatterCandleRadarDataSet, ICandleChartD
super.init()
}

public init(results: RLMResults<RLMObject>?, xValueField: String, highField: String, lowField: String, openField: String, closeField: String, label: String?)
@objc public init(results: RLMResults<RLMObject>?, xValueField: String, highField: String, lowField: String, openField: String, closeField: String, label: String?)
{
_highField = highField
_lowField = lowField
Expand All @@ -50,7 +50,7 @@ open class RealmCandleDataSet: RealmLineScatterCandleRadarDataSet, ICandleChartD
self.init(results: converted, xValueField: xValueField, highField: highField, lowField: lowField, openField: openField, closeField: closeField, label: label)
}

public convenience init(results: RLMResults<RLMObject>?, xValueField: String, highField: String, lowField: String, openField: String, closeField: String)
@objc public convenience init(results: RLMResults<RLMObject>?, xValueField: String, highField: String, lowField: String, openField: String, closeField: String)
{
self.init(results: results, xValueField: xValueField, highField: highField, lowField: lowField, openField: openField, closeField: closeField, label: "DataSet")
}
Expand All @@ -67,7 +67,7 @@ open class RealmCandleDataSet: RealmLineScatterCandleRadarDataSet, ICandleChartD
self.init(results: converted, xValueField: xValueField, highField: highField, lowField: lowField, openField: openField, closeField: closeField)
}

public init(realm: RLMRealm?, modelName: String, resultsWhere: String, xValueField: String, highField: String, lowField: String, openField: String, closeField: String, label: String?)
@objc public init(realm: RLMRealm?, modelName: String, resultsWhere: String, xValueField: String, highField: String, lowField: String, openField: String, closeField: String, label: String?)
{
_highField = highField
_lowField = lowField
Expand All @@ -91,10 +91,10 @@ open class RealmCandleDataSet: RealmLineScatterCandleRadarDataSet, ICandleChartD

// MARK: - Data functions and accessors

internal var _highField: String?
internal var _lowField: String?
internal var _openField: String?
internal var _closeField: String?
@objc internal var _highField: String?
@objc internal var _lowField: String?
@objc internal var _openField: String?
@objc internal var _closeField: String?

internal override func buildEntryFromResultObject(_ object: RLMObject, x: Double) -> ChartDataEntry
{
Expand Down
4 changes: 2 additions & 2 deletions ChartsRealm/Classes/Data/RealmPieDataSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ open class RealmPieDataSet: RealmBaseDataSet, IPieChartDataSet
super.init()
}

public init(results: RLMResults<RLMObject>?, yValueField: String, labelField: String?)
@objc public init(results: RLMResults<RLMObject>?, yValueField: String, labelField: String?)
{
_labelField = labelField

Expand All @@ -50,7 +50,7 @@ open class RealmPieDataSet: RealmBaseDataSet, IPieChartDataSet

// MARK: - Data functions and accessors

internal var _labelField: String?
@objc internal var _labelField: String?

internal override func buildEntryFromResultObject(_ object: RLMObject, x: Double) -> ChartDataEntry
{
Expand Down
2 changes: 1 addition & 1 deletion ChartsRealm/Classes/Data/RealmScatterDataSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ open class RealmScatterDataSet: RealmLineScatterCandleRadarDataSet, IScatterChar

/// Sets the ScatterShape this DataSet should be drawn with.
/// This will search for an available IShapeRenderer and set this renderer for the DataSet
open func setScatterShape(_ shape: ScatterChartDataSet.Shape)
@objc open func setScatterShape(_ shape: ScatterChartDataSet.Shape)
{
self.shapeRenderer = ScatterChartDataSet.renderer(forShape: shape)
}
Expand Down
Loading