I've run into a scenario where two CBLModel subclasses implement the same interface and I want to store a reference to either of these subclasses as a property on a third CBLModel subclass.The compeller doesn't complain, but I was unsure if CBLModel handle this scenario correctly. Note: both CBLModel classes whom implement the same interface have a type property and are registered with CBLModelFactory.
This will work fine. Internally, CBLModel calls the model-factory to resolve the docID into a model instance.—Jens
I'm trying to define...@property (nonatomic, assign) NSArray *objectsThatImplementMyProtocol;From what I understand, we implement the class method: + (Class) itemClassForArrayProperty: (NSString*)property to define the type of objects in the array. However, I'm not sure how this would work in the above case, as the method returns an Objective-C Class type rather than a protocol.
Hm, good point. You can look at the implementation in CBLModel to see what it’s doing; IIRC, the Class returned from itemClassForArrayProperty: is only used if the CBLModelFactory doesn’t know what class to use for that particular document. So as long as you’ve registered the document ‘type’ property (or whatever) with the factory, it should be OK.—Jens