Closed modamoda closed 9 years ago
@modamoda hey man, sorry but I don't really like the idea :( I really think that types are important, especially for type checking and warnings at runtime.
Thanks for your reply. :) I totally agree with you that types are important
But if you are worrying about type safety, it does check safety both runtime and compile time.
The first parameter id<DCMapping>
checks it at compile time. and isKindOfClass
checks it at runtime.
- (void)addMapper: (id<DCMapping>)mapper {
if ([mapper isKindOfClass:[DCArrayMapping class]]){
[self addArrayMapper:mapper];
} else if ([mapper isKindOfClass:[DCObjectMapping class]]){
[self addObjectMapping:mapper];
} else {
@throw [NSException exceptionWithName:NSInternalInconsistencyException
reason:[NSString stringWithFormat:@"unknown mapper class: %@", NSStringFromClass([mapper class])]
userInfo:nil];
}
}
If you find any problem that I missed, please let me know :smile:
@modamoda cool, accepted :) would you mind to create a new podspec for those new reviews? it's great to receive pullrequest from you, thx a lot.
@modamoda oh, I forgot. could you also add a unit test to cover the exception case? just to make sure everything is tested. thx
Sure, why not? I'll work on it.
Please refer to dchohfi#69 : Sugar API that supports
addObjectMapping
andaddArrayMapper
in single API