Skip to content

Commit 1498be9

Browse files
committed
fix for toCKRecord
1 parent fa65a1a commit 1498be9

File tree

5 files changed

+112
-8
lines changed

5 files changed

+112
-8
lines changed

EVReflection.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "EVReflection"
3-
s.version = "5.5.0"
3+
s.version = "5.5.1"
44
s.summary = "Reflection based object mapping. (Dictionary, CKRecord, NSManagedObject, Realm, JSON, XML, Alamofire, Moya, RxSwift, ReactiveSwift)"
55

66
s.description = <<-EOS

EVReflection.xcworkspace/xcuserdata/evermeer.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,102 @@
22
<Bucket
33
type = "0"
44
version = "2.0">
5+
<Breakpoints>
6+
<BreakpointProxy
7+
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
8+
<BreakpointContent
9+
shouldBeEnabled = "Yes"
10+
ignoreCount = "0"
11+
continueAfterRunningActions = "No"
12+
filePath = "Source/CloudKit/CKDataObject.swift"
13+
timestampString = "538923049.33117"
14+
startingColumnNumber = "9223372036854775807"
15+
endingColumnNumber = "9223372036854775807"
16+
startingLineNumber = "140"
17+
endingLineNumber = "140"
18+
landmarkName = "dictToCKRecord(_:dict:types:root:)"
19+
landmarkType = "7">
20+
<Locations>
21+
<Location
22+
shouldBeEnabled = "Yes"
23+
ignoreCount = "0"
24+
continueAfterRunningActions = "No"
25+
symbolName = "EVReflection.CKDataObject.dictToCKRecord(__ObjC.CKRecord, dict: __ObjC.NSDictionary, types: __ObjC.NSDictionary, root: Swift.String) -&gt; ()"
26+
moduleName = "EVReflection"
27+
usesParentBreakpointCondition = "Yes"
28+
urlString = "file:///Users/evermeer/Dev/GitHub/EVReflection/Source/CloudKit/CKDataObject.swift"
29+
timestampString = "538923051.1097471"
30+
startingColumnNumber = "9223372036854775807"
31+
endingColumnNumber = "9223372036854775807"
32+
startingLineNumber = "140"
33+
endingLineNumber = "140"
34+
offsetFromSymbolStart = "5557">
35+
</Location>
36+
<Location
37+
shouldBeEnabled = "Yes"
38+
ignoreCount = "0"
39+
continueAfterRunningActions = "No"
40+
symbolName = "implicit closure #1 : @autoclosure () throws -&gt; Swift.String in EVReflection.CKDataObject.dictToCKRecord(__ObjC.CKRecord, dict: __ObjC.NSDictionary, types: __ObjC.NSDictionary, root: Swift.String) -&gt; ()"
41+
moduleName = "EVReflection"
42+
usesParentBreakpointCondition = "Yes"
43+
urlString = "file:///Users/evermeer/Dev/GitHub/EVReflection/Source/CloudKit/CKDataObject.swift"
44+
timestampString = "538923051.112039"
45+
startingColumnNumber = "9223372036854775807"
46+
endingColumnNumber = "9223372036854775807"
47+
startingLineNumber = "140"
48+
endingLineNumber = "140"
49+
offsetFromSymbolStart = "4">
50+
</Location>
51+
</Locations>
52+
</BreakpointContent>
53+
</BreakpointProxy>
54+
<BreakpointProxy
55+
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
56+
<BreakpointContent
57+
shouldBeEnabled = "Yes"
58+
ignoreCount = "0"
59+
continueAfterRunningActions = "No"
60+
filePath = "Source/CloudKit/CKDataObject.swift"
61+
timestampString = "538923049.331256"
62+
startingColumnNumber = "9223372036854775807"
63+
endingColumnNumber = "9223372036854775807"
64+
startingLineNumber = "142"
65+
endingLineNumber = "142"
66+
landmarkName = "dictToCKRecord(_:dict:types:root:)"
67+
landmarkType = "7">
68+
<Locations>
69+
<Location
70+
shouldBeEnabled = "Yes"
71+
ignoreCount = "0"
72+
continueAfterRunningActions = "No"
73+
symbolName = "EVReflection.CKDataObject.dictToCKRecord(__ObjC.CKRecord, dict: __ObjC.NSDictionary, types: __ObjC.NSDictionary, root: Swift.String) -&gt; ()"
74+
moduleName = "EVReflection"
75+
usesParentBreakpointCondition = "Yes"
76+
urlString = "file:///Users/evermeer/Dev/GitHub/EVReflection/Source/CloudKit/CKDataObject.swift"
77+
timestampString = "538923051.1148781"
78+
startingColumnNumber = "9223372036854775807"
79+
endingColumnNumber = "9223372036854775807"
80+
startingLineNumber = "142"
81+
endingLineNumber = "142"
82+
offsetFromSymbolStart = "8128">
83+
</Location>
84+
<Location
85+
shouldBeEnabled = "Yes"
86+
ignoreCount = "0"
87+
continueAfterRunningActions = "No"
88+
symbolName = "implicit closure #2 : @autoclosure () throws -&gt; Swift.String in EVReflection.CKDataObject.dictToCKRecord(__ObjC.CKRecord, dict: __ObjC.NSDictionary, types: __ObjC.NSDictionary, root: Swift.String) -&gt; ()"
89+
moduleName = "EVReflection"
90+
usesParentBreakpointCondition = "Yes"
91+
urlString = "file:///Users/evermeer/Dev/GitHub/EVReflection/Source/CloudKit/CKDataObject.swift"
92+
timestampString = "538923051.117417"
93+
startingColumnNumber = "9223372036854775807"
94+
endingColumnNumber = "9223372036854775807"
95+
startingLineNumber = "142"
96+
endingLineNumber = "142"
97+
offsetFromSymbolStart = "4">
98+
</Location>
99+
</Locations>
100+
</BreakpointContent>
101+
</BreakpointProxy>
102+
</Breakpoints>
5103
</Bucket>

Source/CloudKit/CKDataObject.swift

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ open class CKDataObject: EVObject {
115115
if record == nil {
116116
record = CKRecord(recordType: EVReflection.swiftStringFromClass(self), recordID: self.recordID)
117117
}
118-
let (fromDict, _) = EVReflection.toDictionary(self)
119-
dictToCKRecord(record, dict: fromDict)
118+
let (fromDict, fromTypes) = EVReflection.toDictionary(self)
119+
dictToCKRecord(record, dict: fromDict, types: fromTypes)
120120

121121
return record
122122
}
@@ -128,15 +128,21 @@ open class CKDataObject: EVObject {
128128
- parameter dict: the dictionary
129129
- parameter root: used for expanding the property name
130130
*/
131-
internal func dictToCKRecord(_ record: CKRecord, dict: NSDictionary, root: String = "") {
131+
internal func dictToCKRecord(_ record: CKRecord, dict: NSDictionary, types: NSDictionary, root: String = "") {
132132
for (key, value) in dict {
133133
if !(["recordID", "recordType", "creationDate", "creatorUserRecordID", "modificationDate", "lastModifiedUserRecordID", "recordChangeTag", "encodedSystemFields"]).contains(key as! String) {
134134
if value is NSNull {
135135
// record.setValue(nil, forKey: key) // Swift can not set a value on a nulable type.
136136
} else if let dict = value as? NSDictionary {
137-
dictToCKRecord(record, dict: dict, root: "\(root)\(key as! String)__")
137+
dictToCKRecord(record, dict: dict, types: types[key] as! NSDictionary, root: "\(root)\(key as! String)__")
138138
} else if key as! String != "recordID" {
139-
record.setValue(value, forKey: "\(root)\(key as! String)")
139+
if types[key] as? String == "CKRecordID" {
140+
record.setValue(CKRecordID(recordName: value as? String ?? ""), forKey: "\(root)\(key as! String)")
141+
} else if types[key] as? String == "CKRefference" {
142+
record.setValue(CKReference(recordID: CKRecordID(recordName: value as? String ?? ""), action: CKReferenceAction.none), forKey: "\(root)\(key as! String)")
143+
} else {
144+
record.setValue(value, forKey: "\(root)\(key as! String)")
145+
}
140146
}
141147
}
142148
}

Source/CloudKit/CKRecord+EVReflectable.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ public extension CKRecord {
2626
} else {
2727
self.init(recordType: EVReflection.swiftStringFromClass(dataObject), recordID: dataObject.recordID)
2828
}
29-
let (fromDict, _) = EVReflection.toDictionary(dataObject)
30-
dataObject.dictToCKRecord(self, dict: fromDict)
29+
let (fromDict, fromTypes) = EVReflection.toDictionary(dataObject)
30+
dataObject.dictToCKRecord(self, dict: fromDict, types: fromTypes)
3131
}
3232

3333

0 commit comments

Comments
 (0)