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

Sync with Xcode 9.2, Swift 4.0.3 #14

Merged
merged 1 commit into from
Jan 4, 2018
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
4 changes: 2 additions & 2 deletions Cartfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github "danielgindi/Charts" == 3.0.4
github "realm/realm-cocoa" ~> 2.10
github "danielgindi/Charts" "master"
github "realm/realm-cocoa" "master"
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.4"
github "realm/realm-cocoa" "v2.10.2"
github "danielgindi/Charts" "9706fa140bbce03e0e4fb7f798a3b2a13e8f0eb4"
github "realm/realm-cocoa" "95d69bebbeebf30a5bf00f8923638ed16e3899ce"
4 changes: 4 additions & 0 deletions ChartsRealm.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
5BAE652A1E90EE7700F71CEF /* RealmRadarDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BAE651C1E90EE7700F71CEF /* RealmRadarDataSet.swift */; };
5BAE652B1E90EE7700F71CEF /* RealmScatterDataSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BAE651D1E90EE7700F71CEF /* RealmScatterDataSet.swift */; };
5BAE652C1E90EE7700F71CEF /* ChartsRealm.h in Headers */ = {isa = PBXBuildFile; fileRef = 5BAE651F1E90EE7700F71CEF /* ChartsRealm.h */; settings = {ATTRIBUTES = (Public, ); }; };
B64EF0F11FFB4711001E5CA0 /* RLMSupport.swift in Sources */ = {isa = PBXBuildFile; fileRef = B64EF0F01FFB4711001E5CA0 /* RLMSupport.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -37,6 +38,7 @@
5BAE651D1E90EE7700F71CEF /* RealmScatterDataSet.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RealmScatterDataSet.swift; sourceTree = "<group>"; };
5BAE651F1E90EE7700F71CEF /* ChartsRealm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChartsRealm.h; sourceTree = "<group>"; };
5BAE65201E90EE7700F71CEF /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
B64EF0F01FFB4711001E5CA0 /* RLMSupport.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RLMSupport.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -107,6 +109,7 @@
children = (
5BAE651F1E90EE7700F71CEF /* ChartsRealm.h */,
5BAE65201E90EE7700F71CEF /* Info.plist */,
B64EF0F01FFB4711001E5CA0 /* RLMSupport.swift */,
);
path = "Supporting Files";
sourceTree = "<group>";
Expand Down Expand Up @@ -216,6 +219,7 @@
5BAE65271E90EE7700F71CEF /* RealmLineRadarDataSet.swift in Sources */,
5BAE65241E90EE7700F71CEF /* RealmBubbleDataSet.swift in Sources */,
5BAE652A1E90EE7700F71CEF /* RealmRadarDataSet.swift in Sources */,
B64EF0F11FFB4711001E5CA0 /* RLMSupport.swift in Sources */,
5BAE65281E90EE7700F71CEF /* RealmLineScatterCandleRadarDataSet.swift in Sources */,
5BAE65221E90EE7700F71CEF /* RealmBarLineScatterCandleBubbleDataSet.swift in Sources */,
5BAE65231E90EE7700F71CEF /* RealmBaseDataSet.swift in Sources */,
Expand Down
15 changes: 7 additions & 8 deletions ChartsRealm/Classes/Data/RealmBarDataSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ open class RealmBarDataSet: RealmBarLineScatterCandleBubbleDataSet, IBarChartDat

if results != nil
{
converted = ObjectiveCSupport.convert(object: results!)
converted = ObjectiveCSupport.convert(object: results!) as? RLMResults<RLMObject>
}

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

if results != nil
{
converted = ObjectiveCSupport.convert(object: results!)
converted = ObjectiveCSupport.convert(object: results!) as? RLMResults<RLMObject>
}

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

if results != nil
{
converted = ObjectiveCSupport.convert(object: results!)
converted = ObjectiveCSupport.convert(object: results!) as? RLMResults<RLMObject>
}

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

if results != nil
{
converted = ObjectiveCSupport.convert(object: results!)
converted = ObjectiveCSupport.convert(object: results!) as? RLMResults<RLMObject>
}

self.init(results: converted, yValueField: yValueField, stackValueField: stackValueField)
Expand Down Expand Up @@ -197,13 +197,12 @@ open class RealmBarDataSet: RealmBarLineScatterCandleBubbleDataSet, IBarChartDat
let value = object[_yValueField!]
let entry: BarChartDataEntry

if value is RLMArray
if let array = value as? RLMArray<RLMObject>
{
var values = [Double]()
var iterator = NSFastEnumerationIterator(value as! RLMArray)
while let val = iterator.next()
for val in array
{
values.append((val as! RLMObject)[_stackValueField!] as! Double)
values.append(val[_stackValueField!] as! Double)
}
entry = BarChartDataEntry(x: _xValueField == nil ? x : object[_xValueField!] as! Double, yValues: values)
}
Expand Down
8 changes: 4 additions & 4 deletions ChartsRealm/Classes/Data/RealmBaseDataSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ open class RealmBaseDataSet: ChartBaseDataSet

if results != nil
{
converted = ObjectiveCSupport.convert(object: results!)
converted = ObjectiveCSupport.convert(object: results!) as? RLMResults<RLMObject>
}

self.init(results: converted, xValueField: xValueField, yValueField: yValueField, label: label)
Expand All @@ -90,7 +90,7 @@ open class RealmBaseDataSet: ChartBaseDataSet

if results != nil
{
converted = ObjectiveCSupport.convert(object: results!)
converted = ObjectiveCSupport.convert(object: results!) as? RLMResults<RLMObject>
}

self.init(results: converted, yValueField: yValueField, label: label)
Expand All @@ -107,7 +107,7 @@ open class RealmBaseDataSet: ChartBaseDataSet

if results != nil
{
converted = ObjectiveCSupport.convert(object: results!)
converted = ObjectiveCSupport.convert(object: results!) as? RLMResults<RLMObject>
}

self.init(results: converted, xValueField: xValueField, yValueField: yValueField)
Expand All @@ -124,7 +124,7 @@ open class RealmBaseDataSet: ChartBaseDataSet

if results != nil
{
converted = ObjectiveCSupport.convert(object: results!)
converted = ObjectiveCSupport.convert(object: results!) as? RLMResults<RLMObject>
}

self.init(results: converted, yValueField: yValueField)
Expand Down
4 changes: 2 additions & 2 deletions ChartsRealm/Classes/Data/RealmBubbleDataSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ open class RealmBubbleDataSet: RealmBarLineScatterCandleBubbleDataSet, IBubbleCh

if results != nil
{
converted = ObjectiveCSupport.convert(object: results!)
converted = ObjectiveCSupport.convert(object: results!) as? RLMResults<RLMObject>
}

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

if results != nil
{
converted = ObjectiveCSupport.convert(object: results!)
converted = ObjectiveCSupport.convert(object: results!) as? RLMResults<RLMObject>
}

self.init(results: converted, xValueField: xValueField, yValueField: yValueField, sizeField: sizeField)
Expand Down
4 changes: 2 additions & 2 deletions ChartsRealm/Classes/Data/RealmCandleDataSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ open class RealmCandleDataSet: RealmLineScatterCandleRadarDataSet, ICandleChartD

if results != nil
{
converted = ObjectiveCSupport.convert(object: results!)
converted = ObjectiveCSupport.convert(object: results!) as? RLMResults<RLMObject>
}

self.init(results: converted, xValueField: xValueField, highField: highField, lowField: lowField, openField: openField, closeField: closeField, label: label)
Expand All @@ -61,7 +61,7 @@ open class RealmCandleDataSet: RealmLineScatterCandleRadarDataSet, ICandleChartD

if results != nil
{
converted = ObjectiveCSupport.convert(object: results!)
converted = ObjectiveCSupport.convert(object: results!) as? RLMResults<RLMObject>
}

self.init(results: converted, xValueField: xValueField, highField: highField, lowField: lowField, openField: openField, closeField: closeField)
Expand Down
5 changes: 4 additions & 1 deletion ChartsRealm/Classes/Data/RealmPieDataSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ open class RealmPieDataSet: RealmBaseDataSet, IPieChartDataSet

if results != nil
{
converted = ObjectiveCSupport.convert(object: results!)
converted = ObjectiveCSupport.convert(object: results!) as? RLMResults<RLMObject>
}

self.init(results: converted, yValueField: yValueField, labelField: labelField)
Expand Down Expand Up @@ -124,6 +124,9 @@ open class RealmPieDataSet: RealmBaseDataSet, IPieChartDataSet

/// the color for the slice-text labels
open var entryLabelColor: NSUIColor? = nil

/// the color for the highlighted sector
open var highlightColor: NSUIColor? = nil

// MARK: - NSCopying

Expand Down
4 changes: 2 additions & 2 deletions ChartsRealm/Classes/Data/RealmRadarDataSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ open class RealmRadarDataSet: RealmLineRadarDataSet, IRadarChartDataSet

if results != nil
{
converted = ObjectiveCSupport.convert(object: results!)
converted = ObjectiveCSupport.convert(object: results!) as? RLMResults<RLMObject>
}

self.init(results: converted, yValueField: yValueField, label: label)
Expand All @@ -56,7 +56,7 @@ open class RealmRadarDataSet: RealmLineRadarDataSet, IRadarChartDataSet

if results != nil
{
converted = ObjectiveCSupport.convert(object: results!)
converted = ObjectiveCSupport.convert(object: results!) as? RLMResults<RLMObject>
}

self.init(results: converted, yValueField: yValueField)
Expand Down
138 changes: 138 additions & 0 deletions ChartsRealm/Supporting Files/RLMSupport.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
////////////////////////////////////////////////////////////////////////////
//
// Copyright 2014 Realm Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////
import Realm

extension RLMRealm {
@nonobjc public class func schemaVersion(at url: URL, usingEncryptionKey key: Data? = nil) throws -> UInt64 {
var error: NSError?
let version = __schemaVersion(at: url, encryptionKey: key, error: &error)
guard version != RLMNotVersioned else { throw error! }
return version
}

#if swift(>=3.2)
@nonobjc public func resolve<Confined>(reference: RLMThreadSafeReference<Confined>) -> Confined? {
return __resolve(reference as! RLMThreadSafeReference<RLMThreadConfined>) as! Confined?
}
#else
@nonobjc public func resolve<Confined: RLMThreadConfined>(reference: RLMThreadSafeReference<Confined>) -> Confined? {
return __resolve(reference as! RLMThreadSafeReference<RLMThreadConfined>) as! Confined?
}
#endif
}

extension RLMObject {
// Swift query convenience functions
public class func objects(where predicateFormat: String, _ args: CVarArg...) -> RLMResults<RLMObject> {
return objects(with: NSPredicate(format: predicateFormat, arguments: getVaList(args))) as! RLMResults<RLMObject>
}

public class func objects(in realm: RLMRealm,
where predicateFormat: String,
_ args: CVarArg...) -> RLMResults<RLMObject> {
return objects(in: realm, with: NSPredicate(format: predicateFormat, arguments: getVaList(args))) as! RLMResults<RLMObject>
}
}

public struct RLMIterator<T>: IteratorProtocol {
private var iteratorBase: NSFastEnumerationIterator

internal init(collection: RLMCollection) {
iteratorBase = NSFastEnumerationIterator(collection)
}

public mutating func next() -> T? {
return iteratorBase.next() as! T?
}
}

// Sequence conformance for RLMArray and RLMResults is provided by RLMCollection's
// `makeIterator()` implementation.
extension RLMArray: Sequence {}
extension RLMResults: Sequence {}

extension RLMCollection {
// Support Sequence-style enumeration
public func makeIterator() -> RLMIterator<RLMObject> {
return RLMIterator(collection: self)
}
}

extension RLMCollection {
// Swift query convenience functions
public func indexOfObject(where predicateFormat: String, _ args: CVarArg...) -> UInt {
return indexOfObject(with: NSPredicate(format: predicateFormat, arguments: getVaList(args)))
}

public func objects(where predicateFormat: String, _ args: CVarArg...) -> RLMResults<NSObject> {
return objects(with: NSPredicate(format: predicateFormat, arguments: getVaList(args))) as! RLMResults<NSObject>
}
}

// MARK: - Sync-related
extension RLMSyncManager {
public static var shared: RLMSyncManager {
return __shared()
}
}

extension RLMSyncUser {
public static var current: RLMSyncUser? {
return __current()
}

public static var all: [String: RLMSyncUser] {
return __allUsers()
}

@nonobjc public var errorHandler: RLMUserErrorReportingBlock? {
get {
return __errorHandler
}
set {
__errorHandler = newValue
}
}

public static func logIn(with credentials: RLMSyncCredentials,
server authServerURL: URL,
timeout: TimeInterval = 30,
callbackQueue queue: DispatchQueue = DispatchQueue.main,
onCompletion completion: @escaping RLMUserCompletionBlock) {
return __logIn(with: credentials,
authServerURL: authServerURL,
timeout: timeout,
callbackQueue: queue,
onCompletion: completion)
}
}

extension RLMSyncSession {
public func addProgressNotification(for direction: RLMSyncProgressDirection,
mode: RLMSyncProgressMode,
block: @escaping RLMProgressNotificationBlock) -> RLMProgressNotificationToken? {
return __addProgressNotification(for: direction,
mode: mode,
block: block)
}
}

extension RLMNotificationToken {
@available(*, unavailable, renamed: "invalidate()")
@nonobjc public func stop() { fatalError() }
}
Loading