我是 backendless.com 和 Realm.io 的新手
我需要制作一个简单的表格,其中包含类别和属于类别的少数项目
我从 backendless 获取数据时遇到问题,因为我创建的类必须同时与 backendless 和 Realm 兼容
问题是从后端获取数组:
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<Dish>() // <- my problem
“菜肴”的问题。
Backendless 手册说我应该这样做
https://backendless.com/feature-16-data-retrieval-api-how-to-load-objects-from-an-mbaas-storage/
var locations : [Location] = []
但是 Realm 说它不支持 NSArray,并且可以使用列表格式,
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.'
当我使用 List 从后端获取数组时,数组的描述如下:
▿ [1] : Category {
objectId = 52E0D354-F1B1-2F64-FFD8-B4129ED0DA00;
name = Паста;
listNumber = 2;
imageName = pasta.png;
image = <(null) — 0 total bytes>;
created = 2016-03-12 17:07:35 +0000;
updated = 2016-03-12 17:34:36 +0000;
dishes = (
);
}
没有菜。但事实上他们是。
我该做什么 ?当我使用列表格式时,我不知道如何从后端获取关系数组。