// in interface file of TFForm class
@property (nonatomic, strong) NSArray *fields;
// in implementation file of TFForm class
@dynamic fields;
+ (Class)fieldsItemClass {
return [TFField class];
}
+ (NSString *)fieldsInverseRelation {
return @"form";
}
NSLog(@"fields from form: %@", currentForm.fields);
On Jun 9, 2015, at 11:57 AM, Brendan Duddridge <bren...@gmail.com> wrote:When I access a TFForm instance and try to log the "fields" property, I get null back. Should it automatically create a view and a query for that? Or do I have to do it all manually by creating my own view and query?
CBLDatabase *database = self.document.couchDatabase;
// Do this once per launch, probably right after opening the database:
CBLModelFactory* factory = database.modelFactory;
[factory registerClass:[TFForm class] forDocumentType: @"TFForm"];
[factory registerClass:[TFField class] forDocumentType: @"TFField"];
[factory registerClass:[TFCategory class] forDocumentType: @"TFCategory"];
[factory registerClass:[TFSearch class] forDocumentType: @"TFSearch"];
[factory registerClass:[TFPickList class] forDocumentType: @"TFPickList"];
[factory registerClass:[TFFormLayout class] forDocumentType: @"TFFormLayout"];
[factory registerClass:[TFFormEntry class] forDocumentType:@"TFFormEntry"];
On Jun 11, 2015, at 1:13 PM, Brendan Duddridge <bren...@gmail.com> wrote:What I had to do was set my fields property to be @dynamic. I had incorrectly assumed that would embed the fields array document IDs into my TFForm's document, which I didn't want (in order to reduce conflicts during syncing).
On Jun 11, 2015, at 1:16 PM, Brendan Duddridge <bren...@gmail.com> wrote:Further to this topic of inverse relationships, what happens if I sync and get a new TFField object coming in that should be attached to my TFForm object's fields array? Will that just automatically happen? I may need to add an observer on my fields array to fire off any KVO notifications in order to update my UI with the new field(s) from the sync.