Skip to content

Commit

Permalink
closes #70
Browse files Browse the repository at this point in the history
  • Loading branch information
DenTelezhkin committed Dec 7, 2014
1 parent f798389 commit 93a9c94
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
14 changes: 14 additions & 0 deletions EasyMapping/EKMapper.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ @implementation EKMapper

+ (id)objectFromExternalRepresentation:(NSDictionary *)externalRepresentation withMapping:(EKObjectMapping *)mapping
{
NSParameterAssert([externalRepresentation isKindOfClass:[NSDictionary class]]);
NSParameterAssert([mapping isKindOfClass:[EKObjectMapping class]]);

if (![externalRepresentation isKindOfClass:[NSDictionary class]] ||
![mapping isKindOfClass:[EKObjectMapping class]])
{
return nil;
}

id object = [[mapping.objectClass alloc] init];
return [self fillObject:object fromExternalRepresentation:externalRepresentation withMapping:mapping];
}
Expand Down Expand Up @@ -76,6 +85,11 @@ + (NSArray *)arrayOfObjectsFromExternalRepresentation:(NSArray *)externalReprese
NSParameterAssert([externalRepresentation isKindOfClass:[NSArray class]]);
NSParameterAssert([mapping isKindOfClass:[EKObjectMapping class]]);

if (![externalRepresentation isKindOfClass:[NSArray class]] ||
![mapping isKindOfClass:[EKObjectMapping class]]) {
return nil;
}

NSMutableArray *array = [NSMutableArray array];
for (NSDictionary *representation in externalRepresentation) {
id parsedObject = [self objectFromExternalRepresentation:representation withMapping:mapping];
Expand Down
5 changes: 5 additions & 0 deletions EasyMapping/EKPropertyHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ + (NSString *) propertyTypeStringRepresentationFromProperty:(objc_property_t)pro

+ (id)propertyRepresentation:(NSArray *)array forObject:(id)object withPropertyName:(NSString *)propertyName
{
if (!array)
{
return nil;
}

objc_property_t property = class_getProperty([object class], [propertyName UTF8String]);
if (property)
{
Expand Down

0 comments on commit 93a9c94

Please sign in to comment.