Latest 2.0.0
Homepage https://github.com/kingslay/KSJSONHelp
License MIT
Platforms ios 8.0, tvos 9.0, osx 10.9
Authors

a lightweight and pure Swift implemented library for

  • conversion between JSON and model.

  • Simple ActiveRecord implementation for working with your database

纯swift实现框架支持

  • json、对象互相转化

  • 解决对象与关系数据库映射,并快速实现 CRUD 操作的对象存储类库

Usage

convert dictionary to model

@objc(Person)
class Person: NSObject, Storable, Model {
    var name: String
    var weight: CGFloat
    var height: NSInteger
    var age: Int64
    var sex: Bool = false
    override required init() {
        name = ""
        age = 1
        height = 11
        weight = 11.111
    }
    init(name: String,age: Int64,height: NSInteger = 11,weight: CGFloat = 11.1111) {
        self.name = name
        self.age = age
        self.height = height
        self.weight = weight
    }
}
let person = Person.fromDictionary(dic)

convert model to dictionary

let dict = person.dictionary

CRUD operate

if let user = Person.fetchOne(dic:["name": "Old Name"]) {
    print("Found (user.name)")
    user.name = "New Name"
    user.save()
    user.delete()
}

Requirements

  • Swift 2

  • Xcode 7

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects.

CocoaPods 0.36 adds supports for Swift and embedded frameworks. You can install it with the following command:

gem install cocoapods

To integrate Kingfisher into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
pod 'KSJSONHelp'

Then, run the following command:

pod install

You should open the {Project}.xcworkspace instead of the {Project}.xcodeproj after you installed anything from CocoaPods.

For more information about how to use CocoaPods, I suggest this tutorial

Carthage

Carthage is a decentralized dependency manager for Cocoa application. To install the carthage tool, you can use Homebrew.

$ brew update

$ brew install carthage

To integrate KSJSONHelp into your Xcode project using Carthage, specify it in your Cartfile:

github "kingslay/KSJSONHelp"

Then, run the following command to build the KSJSONHelp framework:

$ carthage update

At last, you need to set up your Xcode project manually to add the KSJSONHelp framework.

On your application targets’ “General” settings tab, in the “Linked Frameworks and Libraries” section, drag and drop each framework you want to use from the Carthage/Build folder on disk.

On your application targets’ “Build Phases” settings tab, click the “+” icon and choose “New Run Script Phase”. Create a Run Script with the following content:

/usr/local/bin/carthage copy-frameworks

and add the paths to the frameworks you want to use under “Input Files”:

$(SRCROOT)/Carthage/Build/iOS/KSJSONHelp.framework

For more information about how to use Carthage, please see its project page.

Contact

Follow and contact me on Twitter or Sina Weibo. If you find an issue, just open a ticket on it. Pull requests are warmly welcome as well.

Latest podspec

{
    "name": "KSJSONHelp",
    "version": "2.0.0",
    "summary": "swift's MJExtension",
    "description": "KSJSONHelp is a lightweight and pure Swift implemented library fornconversion between JSON and modelnSimple ActiveRecord implementation for working with your database",
    "homepage": "https://github.com/kingslay/KSJSONHelp",
    "license": "MIT",
    "authors": {
        "kingslay": "[email protected]"
    },
    "source": {
        "git": "https://github.com/kingslay/KSJSONHelp.git",
        "tag": "2.0.0"
    },
    "platforms": {
        "ios": "8.0",
        "tvos": "9.0",
        "osx": "10.9"
    },
    "default_subspecs": "Core",
    "module_name": "KSJSONHelp",
    "subspecs": [
        {
            "name": "Core",
            "source_files": "Core/Source/**/*.swift"
        },
        {
            "name": "SQL",
            "source_files": "SQL/Source/**/*.swift",
            "dependencies": {
                "KSJSONHelp/Core": []
            }
        },
        {
            "name": "SQLiteStandalone",
            "source_files": "SQLite/Source/**/*.swift",
            "dependencies": {
                "KSJSONHelp/SQL": [],
                "sqlite3": []
            },
            "xcconfig": {
                "OTHER_SWIFT_FLAGS": "$(inherited) -DSQLITE_SWIFT_STANDALONE"
            }
        }
    ]
}

Pin It on Pinterest

Share This