Hi,
I have two tables, one is “postData”, one is “comment”.
There is a column, comments, in postData table, which is one to many data object relationship and related to comment table.
And I tried to load comments from postData.
Here is my code.
postData.h
@interface postData : NSObject
@property (strong, nonatomic) NSString *objectId;
@property (strong, nonatomic) NSString *poster;
@property (strong, nonatomic) NSString *title;
@property (strong, nonatomic) NSString *teamColor;
@property (strong, nonatomic) NSString *content;
@property (strong, nonatomic) NSMutableArray <respondData> *responds;
@property (strong, nonatomic) GeoPoint *location;
@end
commentData.h
@protocol respondData
@end
@interface respondData : NSObject
@property (strong, nonatomic) NSString *objectId;
@property (strong, nonatomic) userData *poster;
@property (strong, nonatomic) NSString *comment;
@end
// load posts
[[backendless.persistenceService of:[postData class]] find:query
response:^(BackendlessCollection *posts) {
NSArray *currentPage =[posts getCurrentPage];
for (postData *post in currentPage) {
[postsArray addObject:post];
}
}
error:^(Fault *fault) {
NSLog(@"Server reported an error: %@", fault);
}];
result:
_objectId __NSCFString * @“1A707086-6591-730B-FF17-98A487EB0100”
_poster NSTaggedPointerString * @“A”
_title __NSCFString * @“First Posts”
_teamColor NSTaggedPointerString * @“Red”
_content __NSCFString * @“this is the first post”
_responds __NSArrayM * @“0 elements”
_location GeoPoint * 0x7fcfd9cd0760