Latest 0.6
Homepage https://github.com/AlexandreBarbier/ABModel
License MIT
Platforms ios 8.0
Authors

ABModel is a class that parse a JSon dictionary to create an instance of ABModel.
This class make model cration from REST API easier as you don’t have to parse the server response

Usage

In order to benefit this powerful parsing you just have to create your model class and made it inherit from ABModel.

You must use : INSTANCE_TYPE(dictionary:Dictionary<String, AnyObject>) to create your instance with a JSon dictionary

I use introspection to retrieve all the properties of your model from the JSon.
In order to write less code you just have to name your object’s properties the same way as your JSon keys. If you prefer to code multiple method, you can override replaceKey(key:String) -> String in your ABModel subclass and for each JSon key you want to rename return your property name as a string

Sample

class Example : ABModel {
    var exampleID = 0
    var name = ""
    var tests = []
    public func replaceKey(key:String) -> String {
        if (key == "id") {
            return "exampleID"
        }
    }
}

To create an instance of Example

func createExampleWithDictionary(JSonExample:Dictionary<String, AnyObject>) -> Exemple {
     return Exemple(dictionary:JSonExample)
}

Latest podspec

{
    "name": "ABModel",
    "version": "0.6",
    "summary": "simple class to parse REST response",
    "description": "multiple micro lib to bootstrap ios apps"",
    "homepage": "https://github.com/AlexandreBarbier/ABModel",
    "license": "MIT",
    "authors": {
        "Alexandre Barbier": "[email protected]"
    },
    "social_media_url": "http://twitter.com/abarbier_",
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/AlexandreBarbier/ABModel.git",
        "tag": "0.6"
    },
    "source_files": [
        "ABModel/*.swift",
        "ABModel/*.{h,m}"
    ],
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This