I'm having some trouble figuring out of how make the connection between my app and Parse when a user completes a task in my to-do app. I have created the PFObject for it and I have connected the label up and that works great but I am trying to figure out how to work with Bools in Parse.
let obj = PFObject(className: "Tasks")
obj.setValue(task, forKey: "task")
obj.setValue(self.team, forKey: "team")
obj.setValue(self.checked.isChecked, forKey: "done")
obj.saveInBackgroundWithBlock() {success,error in
if error != nil {
print(error)
return
}
if success {
self.loadTasks()
// self.tasks.insert(obj, atIndex: 0)
}
}
}
}))
"checked" is the class instance of CheckBox (all of the brains of the button/checkbox) and "isChecked" is a Bool with a didSet property that changes the checkbox to checked or unchecked based on whether the button is tapped.
The checkbox works great in the app, it just doesn't sync that action.
This is what I have tried so far but to no avail...
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("TaskCell", forIndexPath: indexPath)
// Configure the cell...
cell.selectionStyle = .None
let idx = tasks[indexPath.row]
let task = idx["task"] as! String
if let label = cell.viewWithTag(1) as? UILabel {
label.text = task
}
let done = idx["done"] as! Bool
if let checkBox = cell.viewWithTag(2) as? UIButton {
checked.isChecked = done
}
return cell
}
Any and all help is welcome.
Aucun commentaire:
Enregistrer un commentaire