[iOS] Problem with saving relation objects

Hi,
I have a problem with creating tables with relations using Swift code. Below I have few objects:







p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'; color: #454545}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'; color: #454545; min-height: 14.0px}



class Review : NSObject {
    
    var title: String?
    var place: Place?
    var reviewParts: [ReviewPart] = []
    
}


class Place : NSObject {
    
    var name: String?
    var location: Location?
}


class Location : NSObject {
    
    var longitude = 0.0
    var latitude = 0.0
}


class ReviewPart : NSObject {
    
    var title: String?
    var reviewContent: String?
    var images: [Image] = []
}


class Image : NSObject {


    var url: String
    var width = 0
    var height = 0
    
    init(url: String) {
        self.url = url
    }






p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'; color: #454545}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'; color: #454545; min-height: 14.0px}








































}

I am creating objects and saving them using SDK save function:







p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'; color: #454545}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'; color: #454545; min-height: 14.0px}



   func createTestObject() {        

        let image1 = Image(url: "")

        image1.height = 50

        image1.width = 50

        

        let image2 = Image(url: "")

        image2.height = 50

        image2.width = 50

        

        let reviewPart = ReviewPart()

        reviewPart.reviewContent = ""

        reviewPart.title = ""

        reviewPart.images.append(image1)

        reviewPart.images.append(image2)

        

        let reviewPart1 = ReviewPart()

        reviewPart1.reviewContent = ""

        reviewPart1.title = ""

        reviewPart1.images.append(image1)

        reviewPart1.images.append(image2)

        

        let location = Location()

        location.latitude = 0.0

        location.longitude = 0.0

        

        let place = Place()

        place.name = ""

        place.location = location

        

        let review = Review()

        review.title = ""

        review.place = place

        review.reviewParts.append(reviewPart)

        review.reviewParts.append(reviewPart1)

        

        Backendless.sharedInstance().data.of(Review.ofClass()).save(review, response: { response in

            debugPrint(response.debugDescription)

        }, error: { error in

            debugPrint(error.debugDescription)

        })

    }

As you can see on image, save function created only one table without relations.

https://www.dropbox.com/s/qbhjbq9tgt0cy4v/b.png?dl=0</img>

Did I done something wrong? I think save function should create tables corresponding to Swift objects.

I would be very grateful for your help. Thanks!

Hi Jarosław,

I assume you are using Backendless 4. Please see the documentation about the relation management in 4.0: https://backendless.com/docs/ios/doc.html#related_objects

Regards,
Mark

Hi,

thank you for your response. I wasn’t aware about Relations API in Backendless 4.
Now it works. Thanks!

Best regards