Skip to content

Added default mapping blocks

Compare
Choose a tag to compare
@ipodishima ipodishima released this 29 Feb 18:12
· 10 commits to master since this release
  • Added WANSCodingStore to the main header
  • Added a way to register default mapping block for specific classes.
    For example, you can now add a default mapping block to turn strings to NSDate
id(^toDateMappingBlock)(id ) = ^id(id value) {
    if ([value isKindOfClass:[NSString class]]) {
        return [defaultDateFormatter dateFromString:value];
    }

    return value;
};

[mapper addDefaultMappingBlock:toDateMappingBlock
           forDestinationClass:[NSDate class]];