- (instancetype)initWithJSON:(id)jsonObject
When saving the nesting CBLModel subclass, encodeAsJSON worked as expected. But when reading, I can only get a __NSCFDictionary, not the NSObject<CBLJSONEncoding> one. And the break point for - (instancetype)initWithJSON:(id)jsonObject is not reached.
Following are the code I tought might be useful, I think I must had missed something:
The Nesting CBLModel
@interface NestingModel : CBLModel
@property (readwrite) NSArray *nestedObjectArray; //An array of the following NestedObject
@end
@implementation NestingModel
@dynamic nestedObjectArray
@end
The Nested NSObject <CBLJSONEncoding>
@interface NestedObject : NSObject <CBLJSONEncoding>
@property (readwrite) NSString *nestedObjectName;
- (instancetype)initWithJSON:(id)jsonObject;
- (id)encodeAsJSON;
@end
@implementation NestedObject
- (id)initWithJSON:(id)jsonObject {
self = [self init];
if(self) {
self. nestedObjectName = jsonObject[@"nestedObjectName"];
}
return self;
}
- (id)encodeAsJSON {
return @{@"nestedObjectName" : self. nestedObjectName};
}
@end
--
You received this message because you are subscribed to the Google Groups "Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mobile-couchba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/bdee77aa-092b-474c-b14a-92ae06f949b2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.