NSObject(FWModel)

@interface NSObject (FWModel)

Model模型解析分类,参考自YYModel

  • 从json创建对象,线程安全。NSDate会按照UTC时间解析,下同

    Declaration

    Objective-C

    + (nullable instancetype)fw_modelWithJson:(nonnull id)json;

    Parameters

    json

    json对象,支持NSDictionary、NSString、NSData

    Return Value

    实例对象,失败为nil

  • 从字典创建对象,线程安全

    Declaration

    Objective-C

    + (nullable instancetype)fw_modelWithDictionary:
        (nonnull NSDictionary *)dictionary;

    Parameters

    dictionary

    字典数据

    Return Value

    实例对象,失败为nil

  • 从json创建Model数组

    Declaration

    Objective-C

    + (nullable NSArray *)fw_modelArrayWithJson:(nonnull id)json;

    Parameters

    json

    json对象,支持NSDictionary、NSString、NSData

    Return Value

    Model数组

  • 从json创建Model字典

    Declaration

    Objective-C

    + (nullable NSDictionary *)fw_modelDictionaryWithJson:(nonnull id)json;

    Parameters

    json

    json对象,支持NSDictionary、NSString、NSData

    Return Value

    Model字典

  • 从json对象设置对象属性

    Declaration

    Objective-C

    - (BOOL)fw_modelSetWithJson:(nonnull id)json;

    Parameters

    json

    json对象,支持NSDictionary、NSString、NSData

    Return Value

    是否设置成功

  • 从字典设置对象属性

    Declaration

    Objective-C

    - (BOOL)fw_modelSetWithDictionary:(nonnull NSDictionary *)dictionary;

    Parameters

    dictionary

    字典数据

    Return Value

    是否设置成功

  • 转换为json对象

    Declaration

    Objective-C

    - (nullable id)fw_modelToJsonObject;

    Return Value

    json对象,如NSDictionary、NSArray,失败为nil

  • 转换为json字符串数据

    Declaration

    Objective-C

    - (nullable NSData *)fw_modelToJsonData;

    Return Value

    NSData,失败为nil

  • 转换为json字符串

    Declaration

    Objective-C

    - (nullable NSString *)fw_modelToJsonString;

    Return Value

    NSString,失败为nil

  • 从属性拷贝当前对象

    Declaration

    Objective-C

    - (nullable id)fw_modelCopy;

    Return Value

    拷贝对象,失败为nil

  • 对象编码

    Declaration

    Objective-C

    - (void)fw_modelEncodeWithCoder:(nonnull NSCoder *)aCoder;
  • 对象解码

    Declaration

    Objective-C

    - (nonnull id)fw_modelInitWithCoder:(nonnull NSCoder *)aDecoder;
  • 对象的hash编码

    Declaration

    Objective-C

    - (NSUInteger)fw_modelHash;
  • 比较Model

    Declaration

    Objective-C

    - (BOOL)fw_modelIsEqual:(nonnull id)model;
  • 对象描述

    Declaration

    Objective-C

    - (nonnull NSString *)fw_modelDescription;