我试图一次将多个对象从一个数组设置为Parses数据库,尽管发生的一切只是设置其中一个对象而不是所有对象。不知道我哪里出错了,代码:
var user2 = [PFUser]() //array of PFUsers.
let addRoomObject = PFObject(className: "Room")
for user in user2 {
println(user) //prints two multiple objects
addRoomObject["user1"] = PFUser.currentUser()
addRoomObject["user2"] = user
addRoomObject.saveInBackgroundWithBlock({ (success: Bool!, error: NSError!) -> Void in
if success == true {
println("Added new users to room")
}
})
}
答案 0 :(得分:0)
您可以使用
PFObject.saveAllInBackground(array, block: {
(succeeded: Bool, error: NSError!) -> Void in
// you code here
})
代替。
祝你好运