diff --git a/EasyMapping/EKMapper.m b/EasyMapping/EKMapper.m index e84c5af..d746f20 100644 --- a/EasyMapping/EKMapper.m +++ b/EasyMapping/EKMapper.m @@ -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]; } @@ -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]; diff --git a/EasyMapping/EKPropertyHelper.m b/EasyMapping/EKPropertyHelper.m index c3630e5..5b4eb4e 100644 --- a/EasyMapping/EKPropertyHelper.m +++ b/EasyMapping/EKPropertyHelper.m @@ -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) {