不能使用类型为“(String, equalTo: String?!)”的参数调用 'whereKey'
cannot invoke 'whereKey' with an argument its of type '(String, equalTo: String?!)'
我在这段代码的这一行收到此错误消息:
findSweeter.whereKey("objectId", equalTo: sweet.objectForKey("sweeter")!.objectId)
错误:
cannot invoke 'whereKey' with an argument its of type '(String,
equalTo: String?!)'
这是我在 cellForRowAtiIndex
路径中用来检索要在单元格中显示的个人资料图片、个人资料名称和内容的代码:
var findSweeter:PFQuery = PFUser.query()!
findSweeter.whereKey("objectId", equalTo: sweet.objectForKey("sweeter")!.objectId)
findSweeter.findObjectsInBackgroundWithBlock{
(objects:[AnyObject]?, error:NSError?)->Void in
if error == nil{
let user:PFUser = (objects as! NSArray).lastObject as! PFUser
cell.usernameLabel.text = user.username
UIView.animateWithDuration(0.5, animations: {
cell.sweetTextView.alpha = 1
cell.timestampLabel.alpha = 1
cell.usernameLabel.alpha = 1
cell.profilePic.alpha = 1
})
}
}
如果能解决此问题,我们将不胜感激。使用 Xcode 6.3.2。提前致谢!
尝试在查询之前解包可选变量。
if let sweeter: PFObject = sweet.objectForKey("sweeter") as? PFObject {
var findSweeter:PFQuery = PFUser.query()!
findSweeter.whereKey("objectId", equalTo: sweeter.objectId)
findSweeter.findObjectsInBackgroundWithBlock {
// ...
}
}
我在这段代码的这一行收到此错误消息:
findSweeter.whereKey("objectId", equalTo: sweet.objectForKey("sweeter")!.objectId)
错误:
cannot invoke 'whereKey' with an argument its of type '(String, equalTo: String?!)'
这是我在 cellForRowAtiIndex
路径中用来检索要在单元格中显示的个人资料图片、个人资料名称和内容的代码:
var findSweeter:PFQuery = PFUser.query()!
findSweeter.whereKey("objectId", equalTo: sweet.objectForKey("sweeter")!.objectId)
findSweeter.findObjectsInBackgroundWithBlock{
(objects:[AnyObject]?, error:NSError?)->Void in
if error == nil{
let user:PFUser = (objects as! NSArray).lastObject as! PFUser
cell.usernameLabel.text = user.username
UIView.animateWithDuration(0.5, animations: {
cell.sweetTextView.alpha = 1
cell.timestampLabel.alpha = 1
cell.usernameLabel.alpha = 1
cell.profilePic.alpha = 1
})
}
}
如果能解决此问题,我们将不胜感激。使用 Xcode 6.3.2。提前致谢!
尝试在查询之前解包可选变量。
if let sweeter: PFObject = sweet.objectForKey("sweeter") as? PFObject {
var findSweeter:PFQuery = PFUser.query()!
findSweeter.whereKey("objectId", equalTo: sweeter.objectId)
findSweeter.findObjectsInBackgroundWithBlock {
// ...
}
}