-1

i dont have that much experience so please be friendly while explaining

i can't update my boolean value through swift.

 let parseQuery = PFQuery(className: "request")        
    parseQuery.findObjectsInBackgroundWithBlock { (objects, error) -> Void in
        if let objects = objects {
        for object in objects {

        object.setValue(false, forKey: "isRead") //tried this and didn't work
        object["isRead"] = false //tried this and didn't work as well..

            }
      }
}

the method i use to update my boolean is wrong?

  • What's the type of the `object` in your for-loop? – Laffen Feb 16 '16 at 13:41
  • 2
    Try this ``object["isRead"] = NSNumber(bool: false)`` or ``object.setValue(NSNumber(bool: false), forKey: "isRead")`` – Allen Feb 16 '16 at 13:41
  • What do you mean by "didn't work"? Did it not update the object in the backend? Did it not compile? Did it throw an error at runtime? Did it create a worm hole to a dimension where you never asked this question? – EmilioPelaez Feb 16 '16 at 15:49
  • Parse is now longer working so you should find another backend service – Alex Zanfir Feb 16 '16 at 15:45

3 Answers3

1

Don't forget to saveEventually()

object["isRead"] = NSNumber(bool: false)
object.saveEventually()
Franck
  • 8,939
  • 8
  • 39
  • 57
0

You will need to set the ACL of your object. When saving objects to Parse, write something like this

object.ACL.setPublicWriteAccess(true)

For the existing objects, go into your class and scroll to the right to the ACL. Then set the public write access to true. Hope this helps.

Pranav Wadhwa
  • 7,666
  • 6
  • 39
  • 61
0

You never saved your objects after updating them.

pbush25
  • 5,228
  • 2
  • 26
  • 35