Latest 0.0.6
Homepage https://github.com/cwn152522/MYToolKit
License MIT
Platforms ios 8.0
Frameworks UIKit
Authors

oc、swift的一些小工具类封装(autolayout、json模型转化等),支持cocoapods

MYAutolayout

oc基于链式编程实现的自动布局库,简化布局代码

MYSwiftJsonModel

swift基于codable协议封装的json-model转化库,代码量不多,大多数工作都系统做了。不同于其他模型转换库封装思想,对于同一个模型,可适用于多种json格式

使用方法:
Image text
如图,第一个参数是目标模型类,第二个参数是json字典,第三个参数是映射字典

接下来我们来看一个具体的例子

模型类:需要实现codable协议
Image text

待解析json数据
Image text

映射字典(1.模型定义的Author,json数据里是author 2.模型嵌套了模型(且子模型名也存在不一致情况) 3.模型嵌套了模型数组)
Image text

转换结果

MYToolKit

Latest podspec

{
    "name": "MYToolKit",
    "platforms": {
        "ios": "8.0"
    },
    "version": "0.0.6",
    "swift_version": "4.0",
    "summary": "u8fd9u662fu4e00u4e2au5de5u5177u5e93uff0cu4e3bu8981u653eu4e00u4e9bu7ecfu5e38u8981u7528u7684u5de5u5177u7c7buff0cu6bd4u5982u94feu5f0fu5b9eu73b0u7684u81eau52a8u5e03u5c40u3001xibu7ea6u675fu9002u914du3001xibu5b57u4f53u9002u914du7b49",
    "homepage": "https://github.com/cwn152522/MYToolKit",
    "license": "MIT",
    "authors": {
        "cwn": "[email protected]"
    },
    "source": {
        "git": "https://github.com/cwn152522/MYToolKit.git",
        "tag": "0.0.6"
    },
    "frameworks": "UIKit",
    "subspecs": [
        {
            "name": "MYAutolayout",
            "source_files": "source_files/MYAutolayout/*.{h,m}"
        },
        {
            "name": "MYJsonModel",
            "source_files": "source_files/MYJsonModel/*.{h,m,swift}"
        },
        {
            "name": "MYTableReuseId",
            "source_files": "source_files/MYTableReuseId/*.{h,m}"
        }
    ]
}

Pin It on Pinterest

Share This