Giter VIP home page Giter VIP logo

swiftyconfiguration's Introduction

SwiftyConfiguration

Carthage compatible Pod Version Pod Platform Pod License Swift version

SwiftyConfiguration is modern Swift API for Plist.

Usage

1. Create Plist

create plist file and add your project.

plist.png

2. Define your plist keys
extension Keys {
    static let string      = Key<String>("string")
    static let url         = Key<NSURL>("url")
    static let number      = Key<NSNumber>("number")
    static let int         = Key<Int>("int")
    static let float       = Key<Float>("float")
    static let double      = Key<Double>("double")
    static let date        = Key<NSDate>("date")
    static let bool        = Key<Bool>("bool")
    static let array       = Key<Array<AnyObject>>("array")
    static let dictionary  = Key<[String : String]>("dictionary")
    
    // Support nested value.
    static let innerInt    = Key<Int>("array.0")
    static let innerArray  = Key<String>("array.1.0")
    static let innerString = Key<String>("dictionary.innerString")
}
3. Just use it!
let plistPath = NSBundle.mainBundle().pathForResource("Configuration", ofType: "plist")!
let config = Configuration(plistPath: plistPath)!

// You can get a plist value to type-safe.
let stringValue      = config.get(.string)!
let urlValue         = config.get(.url)!
let numberValue      = config.get(.number)!
let intValue         = config.get(.int)!
let floatValue       = config.get(.float)!
let doubleValue      = config.get(.double)!
let dateValue        = config.get(.date)!
let boolValue        = config.get(.bool)!
let arrayValue       = config.get(.array)!
let dictionaryValue  = config.get(.dictionary)!
let innerIntValue    = config.get(.innerInt)!
let innerArrayValue  = config.get(.innerArray)!
let innerStringValue = config.get(.innerString)!

Installation

Carthage

SwiftyConfiguration is available through Carthage. To install it, simply add the following line to your Cartfile:

github "ykyouhei/SwiftyConfiguration"

CocoaPods

SwiftyConfiguration is available on CocoaPods. Add the following to your Podfile:

pod 'SwiftyConfiguration'

Manually

Just add the Classes folder to your project.

swiftyconfiguration's People

Contributors

ykyouhei avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.