Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion JTObjectMapping/Source/NSObject+JTObjectMapping.m
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,21 @@ - (BOOL)isValidMappingValue {
@implementation NSNull (JTValidMappingValue)

- (void)configureSelfToObject:(NSObject *)object forKey:(NSString *)key {
[object setValue:nil forKey:key];
unsigned int propertyCount = 0;
objc_property_t *properties = class_copyPropertyList([object class], &propertyCount);

for (unsigned int i = 0; i < propertyCount; ++i) {
objc_property_t property = properties[i];
NSString *strName = [NSString stringWithCString:property_getName(property) encoding:NSUTF8StringEncoding];
if ([strName isEqualToString:key])
NSString *strAttributes = [NSString stringWithCString:property_getAttributes(property) encoding:NSUTF8StringEncoding];
if ([strAttributes hasPrefix:@"T@"]) {
[object setValue:nil forKey:key];
} else {
[object setValue:@0 forKey:key];
}
}
}
}

@end