-
Notifications
You must be signed in to change notification settings - Fork 76
Description
Hi Conrad
I am trying to use MMRecordResponse directly to parse and handle the JSON response of a web service bypassing MMRecord and I'd need to use a custom subclass of MMRecordRepresentation, but I noticed that MMRecordResponse depends on a tight coupling between MMRecord and the corresponding NSManagedObject:
- (id)initWithEntity:(NSEntityDescription *)entity {
if (self = [super init]) {
NSParameterAssert([NSClassFromString([entity managedObjectClassName]) isSubclassOfClass:[MMRecord class]]);
_entity = entity;
_protoRecords = [NSMutableSet set];
Class MMRecordClass = NSClassFromString([entity managedObjectClassName]);
Class MMRecordRepresentationClass = [MMRecordClass representationClass];
_representation = [[MMRecordRepresentationClass alloc] initWithEntity:entity];
_hasRelationshipPrimaryKey = [_representation hasRelationshipPrimaryKey];
_prototypeDictionary = [NSMutableDictionary dictionary];
}
return self;
}This is ok when MMRecord is used as designed (subclassing MMRecord) but as a user it would be great to use MMRecordResponse alone. As far as I can understand the rest of the framework, this is the only point that i can see where the marshaler part depends on this design choice: is it correct? What do you think? Would you consider a PR that handle this, defaulting to your implementation but allowing to decouple MMRecordResponse and MMRecord?
More broadly, I think that MMRecord is great when used as designed (model classes as subclasses of MMRecord), but I like the modular nature of the framework and in some occasions as a user I'd rather to handle pure NSManagedObject subclasses, i.e. to decouple local data storage handling and communication with the web services.