Skip to content
This repository was archived by the owner on Jun 4, 2021. It is now read-only.
Open
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 .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ os:
language: generic
sudo: required
dist: trusty
osx_image: xcode9.2
osx_image: xcode10
script:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
DIR="$(pwd)";
cd ..;
export SWIFT_VERSION=4.0.3;
export SWIFT_VERSION=4.1;
wget https://swift.org/builds/swift-${SWIFT_VERSION}-release/ubuntu1404/swift-${SWIFT_VERSION}-RELEASE/swift-${SWIFT_VERSION}-RELEASE-ubuntu14.04.tar.gz;
tar xzf swift-${SWIFT_VERSION}-RELEASE-ubuntu14.04.tar.gz;
export PATH="${PWD}/swift-${SWIFT_VERSION}-RELEASE-ubuntu14.04/usr/bin:${PATH}";
Expand Down
34 changes: 34 additions & 0 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Sources/CKFetchRecordsOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public class CKFetchRecordsOperation: CKDatabaseOperation {
let recordID = strongSelf.recordIDs![index]
strongSelf.progressed(recordID: recordID, progress: progress)

if let record = CKRecord(recordDictionary: recordDictionary) {
if let record = CKRecord(recordDictionary: recordDictionary, recordID: recordID) {
strongSelf.recordIDsToRecords[record.recordID] = record

// Call per record callback, not to be confused with finished
Expand Down
2 changes: 1 addition & 1 deletion Sources/CKPredicateReader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct CKPredicateReader {
}

func hasNext(_ input: Index) -> Bool {
return input + step <= buffer.characters.count
return input + step <= buffer.count
}

func takeCharacter(_ input: Index) -> (Character, Index)? {
Expand Down
3 changes: 2 additions & 1 deletion Sources/CKPrettyError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class CKPrettyError: NSError {

override public var description: String {
// \(withUnsafePointer(to: self))
return "<CKError: \"\(CKErrorCode(rawValue: self.code)?.description)\" (\(self.code)); \(self.userInfo)";
let errorDescription = CKErrorCode(rawValue: self.code)?.description ?? ""
return "<CKError: \"\(errorDescription)\" (\(self.code)); \(self.userInfo)"
}
}
4 changes: 2 additions & 2 deletions Sources/CKQueryOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class CKQueryOperation: CKDatabaseOperation {

public var recordFetchedBlock: ((CKRecord) -> Swift.Void)?

public var queryCompletionBlock: ((CKQueryCursor?, NSError?) -> Swift.Void)?
public var queryCompletionBlock: ((CKQueryCursor?, Error?) -> Swift.Void)?

override func CKOperationShouldRun() throws {
// "Warn: There's no point in running a query if there are no progress or completion blocks set. Bailing early."
Expand All @@ -57,7 +57,7 @@ public class CKQueryOperation: CKDatabaseOperation {

override func finishOnCallbackQueue(error: Error?) {
// log "Operation %@ has completed. Query cursor is %@.%@%@"
self.queryCompletionBlock?(self.resultsCursor, error as? NSError)
self.queryCompletionBlock?(self.resultsCursor, error)

super.finishOnCallbackQueue(error: error)
}
Expand Down
12 changes: 8 additions & 4 deletions Sources/CKRecord.swift
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public class CKRecord: NSObject {
return"<\(type(of: self)); recordType = \(recordType);recordID = \(recordID); values = \(values)>"
}

init?(recordDictionary: [String: Any]) {
init?(recordDictionary: [String: Any], recordID: CKRecordID? = nil) {

guard let recordName = recordDictionary[CKRecordDictionary.recordName] as? String,
let recordType = recordDictionary[CKRecordDictionary.recordType] as? String
Expand All @@ -142,10 +142,14 @@ public class CKRecord: NSObject {
zoneID = CKRecordZoneID(zoneName: CKRecordZoneDefaultName, ownerName: "_defaultOwner")
}

let recordID = CKRecordID(recordName: recordName, zoneID: zoneID)
// self.init(recordType: recordType, recordID: recordID)
if let recordID = recordID {
self.recordID = recordID
} else {
let recordID = CKRecordID(recordName: recordName, zoneID: zoneID)
self.recordID = recordID
}

self.recordType = recordType
self.recordID = recordID

// Parse Record Change Tag
if let changeTag = recordDictionary[CKRecordDictionary.recordChangeTag] as? String {
Expand Down
4 changes: 4 additions & 0 deletions Sources/CKRecordID.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ public class CKRecordID: NSObject {

public var zoneID: CKRecordZoneID

public override func isEqual(_ object: Any?) -> Bool {
guard let other = object as? CKRecordID else { return false }
return self.recordName == other.recordName && self.zoneID == other.zoneID
}
}

extension CKRecordID {
Expand Down
4 changes: 2 additions & 2 deletions Sources/CKReference.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ open class CKReference: NSObject {
self.init(recordID: record.recordID, action: action)
}

open let referenceAction: CKReferenceAction
public let referenceAction: CKReferenceAction

open let recordID: CKRecordID
public let recordID: CKRecordID
}

extension CKReference {
Expand Down
6 changes: 5 additions & 1 deletion Sources/OpenCloudKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,11 @@ public class CKRecordZoneID: NSObject {

self.init(zoneName: zoneName, ownerName: ownerName)
}


public override func isEqual(_ object: Any?) -> Bool {
guard let other = object as? CKRecordZoneID else { return false }
return self.zoneName == other.zoneName && self.ownerName == other.ownerName
}
}


Expand Down