Xcode 8, Swift 3.
The issue is that after emitting a few key value pairs, and then running a query against that view, the value’s are correct but the keys are returning (function)… kind of.
Here’s a snippet of the emit
let k = doc["emp_id"] as! String
let v = doc["emp_name"] as! String
print("emitting key = \(k) value = \(v)")
emit(k, v)
which prints
emitting key = E001 value = Company 1
emitting key = E002 value = Company 2
emitting key = E003 value = Company 3
Then a very simple query
let cblQuEnum = try query.run()
while let queryRow = cblQuEnum.nextRow() {
print("key = \(queryRow.key) value = \(queryRow.value!)")
print("queryRow = \(queryRow)")
let x = queryRow.value(forKey: "key")
print("valueForKey = \(x!)\n")
}
and the output
key = (Function) value = Company1
queryRow = CBLQueryRow[key=“E001”; value=“Company1”; id=-DnBbrZYkM_LAjqxPWhSuGX]
valueForKey = E001
key = (Function) value = Company2
queryRow = CBLQueryRow[key=“E002”; value=“Company2”; id=-ltj_-77Mf5PX6ZMrTIZ49Y]
valueForKey = E002
key = (Function) value = Company3
queryRow = CBLQueryRow[key=“E003”; value=“Company3”; id=-JgtI9UCkjr7SYEo98upg1A]
valueForKey = E003
So, the queryRow contains key=E001 etc, so that checks.
valueForKey = E001, so that’s ok
queryRow.key is a (function)?
Any thoughts as to why queryRow.key is a function when obtaining that other ways is a String?