我有一个定制的TableViewCell,它有一个标签和一个按钮。我有一个Int数组groupVote,它保存将在UITableView中填充标签voteScoreLabel的值。当按钮upVoteButtonPressed被点击时,将使用标记更新到单元格的相应值。但是,在下面的代码中有一个错误(我已经在下面的代码中放置了特定的行),它显示:@lvalue $T5‘与'AnyObject!,当我想更新Parse中的值时,它是不一样的。这意味着什么,以及如何修复它?
@IBAction func upVoteButtonPressed(sender: AnyObject) {
println(groupVote[voteScoreLabel.tag])
groupVote[voteScoreLabel.tag]=groupVote[voteScoreLabel.tag]+1
var messageDisplayTwo = PFQuery(className:currentScreen)
messageDisplayTwo.whereKey("identifier", equalTo:voteScoreLabel.tag )
messageDisplayTwo.findObjectsInBackgroundWithBlock {
(objects: [AnyObject]!, error: NSError!) -> Void in
if error == nil{
for object in objects {
var textNumb=groupVote[self.voteScoreLabel.tag] as Int
object["vote"]=textNumb //Error Right Here: @lvalue $T5' is not identical to 'AnyObject!
}
} else {
// Log details of the failure
}
}发布于 2015-01-28 01:00:49
您需要将objects转换为PFObject数组。
for object in objects as [PFObject] {
var textNumb = groupVote[self.voteScoreLabel.tag] as Int
object["vote"] = textNumb
}发布于 2015-01-28 01:02:54
尝试使用以下语法:
query.findObjectsInBackgroundWithBlock{
(objects: [AnyObject]!, error: NSError!) -> Void in
if (error == nil) {
// objects in results will only contain the playerName and score fields
for object in objects as [PFObject] {
...
...https://stackoverflow.com/questions/28181160
复制相似问题