Ambiguous reference to member 'locations'

Hi Guy`s

I try to repeat this tutorial:

But in line:

self.printLocations(restaurant.locations as [Location])

I will have a error: Ambiguous reference to member ‘locations’
How can I fix that?

import UIKit

class Restaurant : NSObject {

    var locations : [Location]?


class Location : NSObject {

    var streetAdress : String?

    var city : String?


class Load: UIViewController {


    var backendless = Backendless.sharedInstance()

    override func viewDidLoad() {





    func twoStepsLoadRelationsSync() {


        Types.tryblock({ () -> Void in

            var query = BackendlessDataQuery()

            var restaurants =           self.backendless.persistenceService.of(Restaurant.ofClass()).find(query)


            var currentPage = restaurants.getCurrentPage()

            print("Loaded \(currentPage.count) restaurant objects")

            print("Total restaurants in the Backendless starage - \(restaurants.totalObjects)")


            for restaurant in currentPage {

                self.backendless.persistenceService.load(restaurant, relations:["locations"])

                print("Restaurant name = \(")

                self.printLocations(restaurant.locations as [Location])


            }) { (exception) -> Void in

                print("Server reported an error: \(exception as! Fault)")




    func printLocations(locations: [Location]?) {


        if locations == nil {

            print("Restaurant locations have not been loaded")




        if locations?.count == 0 {

            print("There are no related locations")




        for location in locations! {

            print("Location: Street address - \(location.streetAdress), City - \(")




Hi Pascal,

Please try the latest release of this sample in BlogFeatureDay-iOS github.


With the new tutorial it works fine. Thanks.
It will retrieve all objects in Location. How can I right now filter that?
Like: User logged in, retrieve all object in Location witch is in related with Restaurant(Starbucks)
I hope you understand what I mean.

You should use BackendlessDataQuery.whereClause.

Here is guide for Advanced Object Retrieval, please investigate it.

Thanks. How can I retrieve data witch is in a relationship with the Users class?

You need to use the getProperty method on the BackendlessUser object.

Do you have some good tutorials witch are explaining that?

It is right in the documentation:

I understand that. But it shows only how to retrieve “normal” data. How can I retrieve relationships?

You can use the following approach to retrieve user objects. The "query "argument would control the relations:

More details are in the documentation:

Sorry it is so difficult to understand that and the documentation are also not so helpful. Does some videos exist or is a webinar in planing?

I am right now 3 weeks on it and I am just one step closer to understand how I can retrieve a row in Location Class witch is in relation with Restaurant with is in relation with Users (Users->Restaurant->Location)

Do you already have the user object for who you need to loads the restaurant and location?

I will retrieve the data always for the current user.

But I am not sure if you mean that.

If you know objectId of the user for whom you need to load restaurant objects, then you should do the following:

    Send your query to the Restaurant table. That means in the of() method you put Restaurant.ofClass() Set the where clause to: Users[restaurants].objectId = 'objectId-of-the-user-to-get-restaurants-for' This will get all the restaurants of the user in question

    Add query options to the BackendlessDataQuery object with related column for the location (the documentation describes that)

Regards, Mark