For people who are encountering this problem with one-to-many relationship using Array column type,
If you assign the array to the Array column type, then the completion block is not called. However, the data is saved. However, there is no way to visualize the connection in the parse.com dashboard.
I have two tables, User and Education. An User can have multiple Education objects. In the following code, the completion block is never called.
import Parse
var education : [MyEducation] = [MyEducation]()
let edu1 : MyEducation = MyEducation()
edu1["schoolName"] = "Stanford"
edu1["fieldOfStudy"] = "Engineering"
edu1["startDate"] = NSDate()
education.append(edu1)
let edu2 : MyEducation = MyEducation()
edu2["schoolName"] = "UCLA"
edu2["fieldOfStudy"] = "Data Science"
edu2["startDate"] = NSDate()
education.append(edu2)
PFUser.currentUser()?["education"] = education
PFUser.currentUser()?.saveInBackgroundWithBlock{(success: Bool, error: NSError?) -> Void in
let a : Int = 1
}
However, if you code the following, the completion block IS called.
import Parse
var education : [MyEducation] = [MyEducation]()
let edu1 : MyEducation = MyEducation()
edu1["schoolName"] = "Stanford"
edu1["fieldOfStudy"] = "Engineering"
edu1["startDate"] = NSDate()
edu1["user"] = PFUser.currentUser()
education.append(edu1)
let edu2 : MyEducation = MyEducation()
edu2["schoolName"] = "UCLA"
edu2["fieldOfStudy"] = "Data Science"
edu2["startDate"] = NSDate()
edu2.["user"] = PFUser.currentUser()
education.append(edu2)
PFUser.currentUser()?.saveInBackgroundWithBlock{(success: Bool, error: NSError?) -> Void in
let a : Int = 1
}
So in the end, which approach to choose is your call. The former makes visualization harder (or impossible?) in dashboard but you can use includeKey("education") later for PFUser queries.
In the latter approach you must query the Education class for full PFObject but the pointer to User from the Education class is visible in dashboard as well as completion block being called.
I think Parse did not design relation acquisition very well and this behavior is not documented.
NSLog(@"Error: %@", error);. - Andrey Gordeevspouse[@"spouse"] = [PFUser currentUser];and verify thatspouseisn't nil - Paulw11