I have a swift method that I'm using to update Parse in the backend when the button is tapped. Votes are being updated: The method acts as a voting system, incrementing a label every time it's tapped. This action is happening in a Custom Cell:
@IBOutlet weak var votesLabel: UILabel!
var parseObject:PFObject?
@IBAction func happyBtn(sender: AnyObject) {
if(parseObject != nil) {
if var votes: Int? = parseObject!.objectForKey("votes") as? Int {
votes!++
parseObject!.setObject(votes!, forKey: "votes")
parseObject!.saveInBackground()
votesLabel?.text = "+\(votes!)"
// print(votes)
}
}
}
Was wondering how I can optimize this function to send the data to and from Parse in the most efficient manner?
All help is appreciated!