Skip to content
This repository was archived by the owner on Jun 13, 2023. It is now read-only.

Commit 33ec3af

Browse files
kajensenrichardjrossiii
authored andcommitted
Allow pfgeopoints. (#59)
* Allow pfgeopoints. Fixes #58.
1 parent 19845eb commit 33ec3af

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

Sources/ParseLiveQuery/Internal/QueryEncoder.swift

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,36 @@ import Parse
1616
extension Dictionary where Key: StringLiteralConvertible, Value: AnyObject {
1717
init(query: PFQuery) {
1818
self.init()
19-
2019
let queryState = query.valueForKey("state")
2120
if let className = queryState?.valueForKey("parseClassName") {
2221
self["className"] = className as? Value
2322
}
24-
2523
if let conditions: [String:AnyObject] = queryState?.valueForKey("conditions") as? [String:AnyObject] {
26-
self["where"] = conditions as? Value
24+
self["where"] = conditions.encodedQueryDictionary as? Value
25+
}
26+
}
27+
}
28+
29+
extension Dictionary where Key: StringLiteralConvertible, Value: AnyObject {
30+
var encodedQueryDictionary: Dictionary {
31+
var encodedQueryDictionary = Dictionary()
32+
for (key, val) in self {
33+
if let dict = val as? [String:AnyObject] {
34+
encodedQueryDictionary[key] = dict.encodedQueryDictionary as? Value
35+
} else if let geoPoint = val as? PFGeoPoint {
36+
encodedQueryDictionary[key] = geoPoint.encodedDictionary as? Value
37+
} else {
38+
encodedQueryDictionary[key] = val
39+
}
2740
}
41+
return encodedQueryDictionary
42+
}
43+
}
44+
45+
extension PFGeoPoint {
46+
var encodedDictionary: [String:AnyObject] {
47+
return ["__type": "GeoPoint",
48+
"latitude": latitude,
49+
"longitude": longitude]
2850
}
2951
}

0 commit comments

Comments
 (0)