I'm in the process of converting my app from KinveyKit 1.40.9 to Kinvey 3.3.9 and I'm having trouble translating something that used to work in KinveyKit 1.40.9.
The old code goes something like this:
let dictionary: [String: AnyObject] = [ "field1": "value1", "field2": "value2" ] // and so on... let query = KCSQuery( onField: "param", withExactMatchForValue: dictionary as NSObject ) // run query on datastore
I'm not sure how to do the same in Kinvey 3.3.9 or if it even supports this. If I try to do it this way
let dictionary: [String: AnyObject] = [ "field1": "value1", "field2": "value2" ] // and so on... let predicate = NSPredicate( format: "param == %@", dictionary ) let query = Query(predicate: predicate) // run the query on the relevant datastore
the app crashes with a "found nil when unwrapping an optional" error. Putting the dictionary into an array prevents the app from crashing but the query doesn't return the correct results.
Let me know if more information is needed. Any guidance in this matter is much appreciated.
Forgot to add that we're using Swift 3.0.2
Also, the line that crashes the app is line 323 in MongoDBPredicateAdaptor.swift. A variable that is nil is force unwrapped on that line. The reason that the variable is nil is that
transform(constant:modifyingOperator:) -> Any?
doesn't handle dictionaries, which is why I'm not sure if Kinvey still supports this or if it's just an oversight.