func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
let configuration = ParseClientConfiguration {
$0.applicationId = "WhatsTheHW"
$0.server = "https://whatsthehw-parse-alan.herokuapp.com/parse"
}
Parse.initializeWithConfiguration(configuration)
let query = PFQuery(className: "Course")
query.findObjectsInBackgroundWithBlock {(result: [PFObject]?, error: NSError?) -> Void in
for object in result! {
if object.objectId == "34AF1vKO6f" {
object["studentRelation"] = ["hi", "ih"]
object.saveInBackgroundWithBlock{(success, error) in
if success == true {
print("\(object) saved to parse")
} else {
print("save failed: \(error)")
}
}
}
}
}
return true
}
This is the minimum, I can reduce this task (this code is in AppDelegate).
Everything worked fine when I tried using the REST api and api console in the parsing panel, but it does not work with iOS sdk.
The error I get from the print statement is
Error Domain=Parse Code=101 "Object not found." UserInfo={code=101, temporary=0, error=Object not found., NSLocalizedDescription=Object not found.}
It works if I just add a new object as follows:
let object = PFObject(className: "Course")
object["name"] = "German"
object["studentRelation"] = ["a", "b"]
object.saveInBackgroundWithBlock{(success, error) in
if success == true {
print("save completed")
print("\(object) saved to parse")
} else {
print("save failed: \(error)")
}
}
I am really lost, and I do not know why this is happening.
Thanks in advance.
source
share