FWModel

@protocol FWModel <NSObject>

Model转换协议 数组类映射支持两种方式:

  1. 实现fwModelClassMapper方法,返回类映射字典。示例:@{@“books” : [Book class]}
  2. 声明Model类同名协议,同时定义数组属性时也声明协议。示例:NSArray *books Swift数组类映射时,需返回AnyClass类型。示例:[“books”: Book.self]
  • 属性映射,示例:@{@“name” : @“book_name”, @“bookId” : [@“book_id”, @“book.id”]}

    Declaration

    Objective-C

    + (nullable NSDictionary<NSString *, id> *)modelPropertyMapper;
  • 类映射(Swift需使用AnyClass类型),示例:@{@“books” : [Book class], @“users” : @“User”}

    Declaration

    Objective-C

    + (nullable NSDictionary<NSString *, id> *)modelClassMapper;
  • 自定义字典解析类(Swift需使用AnyClass类型)

    Declaration

    Objective-C

    + (nullable Class)modelClassForDictionary:(nonnull NSDictionary *)dictionary;
  • 属性黑名单列表

    Declaration

    Objective-C

    + (nullable NSArray<NSString *> *)modelPropertyBlacklist;
  • 属性白名单列表

    Declaration

    Objective-C

    + (nullable NSArray<NSString *> *)modelPropertyWhitelist;
  • 字典将要转换模型时钩子处理

    Declaration

    Objective-C

    - (nonnull NSDictionary *)modelWillTransformFromDictionary:
        (nonnull NSDictionary *)dictionary;
  • 字典转换模型时钩子处理

    Declaration

    Objective-C

    - (BOOL)modelTransformFromDictionary:(nonnull NSDictionary *)dictionary;
  • 模型转换字典时钩子处理

    Declaration

    Objective-C

    - (BOOL)modelTransformToDictionary:(nonnull NSMutableDictionary *)dictionary;