Recently note that wherekey on PFQuery does not work. I tried 3 approaches but all failed. I am using parse-library-1.7.2 on Xcode 6.3.
Error for approach1: Cannot invoke 'whereKey' with an argument list of type '(String, AnyObject)'
Error for approach2: 'String?'is not convertible to 'StringLiteralConvertible'
Error for approach3: 'AnyObject?' is not convertible to 'String'
Code is as below. Anyone can help with this please? Thanks in advance.
// Define the query that will provide the data for the table view
class MyController: PFQueryTableViewController {
override func queryForTable() -> PFQuery {
var query = PFQuery(className: "Ticket")
//Approach 1
query.whereKey(sellerIdKey, equalTo: currentPhoneUser["objectId"]!)
//Approach 2
if let sellerId = currentPhoneUser["objectId"] as? String {
query.whereKey(sellerIdKey, equalTo: sellerId)
query.orderByDescending("createdAt")
return query
} else {
fatalError("Can't get Object Id of this user")
}
//Approach 3
if let sellerId = currentPhoneUser["objectId"] as! String {
query.whereKey(sellerIdKey, equalTo: sellerId)
query.orderByDescending("createdAt")
return query
} else {
fatalError("Can't get Object Id of this user")
}
}
}