0

i am using Quickblox API in my ios app.i created two custom objects containers in quickblox admin panel named for instance (User, Book).Now my question is how to define relation so that each user can have multiple Books.How to add books to User and save, retrieve and manipulate.

Please suggest me.

  • can anyone tell the right way of doing this.i have come across by using Parent_id we can define a relationship.But still not having right idea for implementing. – Ajay Babu Singineedi Apr 20 '16 at 09:59

1 Answers1

0

This is how i did and worked well.

1.sending single child object to 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.Sending multiple child objects in single request to 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)
           }