Backendless + realm - problem with storing arrays

Hello ! I am new in backendless.
I need to make a simple table with categories and few items that belong to categories
I have a problem with getting data from backendless, because i make class that must be compatible with backendless and Realm.
The problem is getting array from backendless:

class Category: Object {
dynamic var objectId = ""
dynamic var name = ""
dynamic var listNumber = 0
dynamic var imageName = ""
dynamic var image: NSData? = nil
dynamic var created: NSDate?
dynamic var updated: NSDate?
var dishes = List&lt;Dish&gt;() // <- my problem


Problem with ‘dishes’.
Backendless manual says that i should do like this
https://backendless.com/feature-16-data-retrieval-api-how-to-load-objects-from-an-mbaas-storage/

var locations : [Location] = []

but Realm says that it not supports NSArray, and will work with List<Type> Format,

dynamic var dishes: [Dish] = [] // Terminating app due to uncaught exception 'RLMException', reason: ''NSArray' is not supported as an RLMObject property. All properties must be primitives, NSString, NSDate, NSData, RLMArray, or subclasses of RLMObject. See https://realm.io/docs/objc/latest/api/Classes/RLMObject.html for more information.'

But when i get array from backendless , description of array looks like:

▿ [1] : Category {
objectId = 52E0D354-F1B1-2F64-FFD8-B4129ED0DA00;
name = Паста;
listNumber = 2;
imageName = pasta.png;
image = &lt;(null) &mdash; 0 total bytes&gt;;
created = 2016-03-12 17:07:35 +0000;
updated = 2016-03-12 17:34:36 +0000;
dishes = (
);
}

There is no dishes.

What i should do ? Please help.

I found a topic with the same problem
http://support.backendless.com/t/store-data-with-realm-retrieved-by-backendless-same-as-parse-localstorage

but there is no answer what to do

http://support.backendless.com/public/attachments/2ebfbfc7d522b5ffdccc6b759f3b3a27.png&lt;/img&gt;

Hi Alexandr,

Please, show the code of your request to retrieve the data.

Hello Sergey! :slight_smile: That’s my code:





 @IBAction func loadBackendCategories(sender: AnyObject) {
        
            let dataStore = backendless.data.of(Category.ofClass())
            var error: Fault?
    
             let result = dataStore.findFault(&error)
            if error == nil {
                let categories = result.getCurrentPage() as! [Category]
                for var m = 0; m < categories.count; m++ {
                    print("----------------")
                    print(categories[m].objectId)
                    print(categories[m].updated!)
                    print(categories[m].created!)
                    print(categories[m].name)
                    print(categories[m].listNumber)
                    print(categories[m].imageName)
                    print(categories[m].image)
                  //  print(categories[m].dishes.count)
                    
                }
            }
            else {
                print("Server reported an error: \(error)")
            }
    }

Backendless does not return related objects on “find” request by default. This is done to decrease the size of response.
So you should either set “autoload” in your Data Console - which will change the default behaviour and always retrieve this relation, or indicate that you want to load some relations in Query Options. See the example in the docs: https://backendless.com/documentation/data/ios/data_relations_retrieve.htm