我在我的ios app.i中使用Quickblox API在quickblox管理面板中创建了两个自定义对象容器,名为例如(User,Book)。现在我的问题是如何定义关系以便每个用户可以拥有多个Books.How将书籍添加到用户并保存,检索和操作。
请建议我。
答案 0 :(得分:0)
这就是我的表现和工作方式。
1.将单个子对象发送到Quickblox API
let qbCustomObject = QBCOCustomObject()
qbCustomObject.className = "YOUR CLASS NAME"// as given in Quickblox Custom Object
qbCustomObject.fields?.setObject(each.fullName, forKey:"name")
qbCustomObject.fields?.setObject("YOUR PARENT ID", forKey:"_parent_id")
QBRequest.createObject(qbCustomObject,className:"PLProjectMember", successBlock: { (response, contributors) in
//Handle Success
}) { (response) in
//Handle Error
}
2.将单个请求中的多个子对象发送到Quickblox API
var qbObjects:[QBCOCustomObject] = [QBCOCustomObject]()
for each in self!.selectedContributors{
let qbCustomObject = QBCOCustomObject()
qbCustomObject.className = "PLProjectMember"
qbCustomObject.fields?.setObject(each.fullName, forKey:"name")
qbCustomObject.fields?.setObject("YOUR PARENT ID",forKey:"_parent_id")
qbObjects.append(qbCustomObject)
}
QBRequest.createObjects(qbObjects, className:"YOUR CLASS NAME", successBlock: { (response, contributors) in
completion(true)
}) { (response) in
completion(false)
}