Hello, how i can to add new entity in the existing object. According to such scheme.
http://support.backendless.com/public/attachments/9909d185cafcb9c9f857e911b6732e51.png</img>
What is function addContact ?
You’re right addContact is not declared there. It is simply a function that adds contact to the array:
[self.contacts addObject:contact];
It means that in my program I simply have to write it in h. file, and run function add ?
i believe the code would need to go to the .m file. The .h files are just for declarations.
nevertheless I do not understand as it to make. Help please. What i do: i retrieve Object, which have
NSString *ObjectId;
NSString *name;
NSArray<OtherObject *> otherObject;(represented relationships)
Ok, so, i add to this retrieved Object a new OtherObject, and when i save, all OtherObjects, which saved before lose relations with Object. How can i fix this?
Update : Sorry for my English. I use Backendless service. I have two entity: Object and Object2. Object have property:
- NSString *objectID;
NSString *objectName;
NSMutableArray < Object2* > *object2; (represented relationship).
[backendless.persistenceService update:Object response:^(id regs) {
} error:^(Fault *error) {
}];How can i fix this?
Can you help me?
Hi,
By default when an object is retrieved from Backendless using any of the find APIs (basic or advanced), its related objects are not included into the response.
For your purpose you can use Relations Auto Load. Check on autoload checkbox on Object2 1:N relation in Object table, and you will retrieve your Object objects with Object2 1:N relation.
Another way (without autoload) is to use methods supporting relation depth, for example (in swift):
let dataStore = backendless.data.of(Object.ofClass())
var error: Fault?
let object = dataStore.findFirst(1, fault:&error) as? Object
if error == nil {
print("Found: \(object!)")
updateObject(object!)
}
else {
print("Server reported an error (2): \(error)")
}
Regards,
Slava