Giter Site home page Giter Site logo

ios-alamofire-demo's Introduction

ios-alamofire-demo

iOS Alamofire・ObjectMapper・KingFisherを利用したデモ(Swift3)

Alamofire

HTTP通信を行うライブラリ

1. PodFile

pod 'Alamofire'

2. import する

import Alamofire

3. 使い方(Usage)

Alamofire.request(APIClient.ulrString, method: .get).responseJSON { response in

    switch response.result {

    case .success(let value):
        completionHandler(Result.success(value))

    case .failure:
        if let error = response.result.error {
            completionHandler(Result.failure(error))
        } else {
            fatalError("errorインスタンスがnil")
        }
    }
}

ObjectMapper

JSONなどをオブジェクトへマッピングするライブラリ

1. PodFile

pod 'ObjectMapper'

2. import する

import ObjectMapper

3. 使い方(Usage)

struct Forecast: Mappable {

    var dateLabel = ""
    var telop = ""
    var image: ForecastImage?

    init?(map: Map) {}

    mutating func mapping(map: Map) {

        dateLabel <- map["dateLabel"]
        telop <- map["telop"]
        image <- map["image"]
    }
}

Kingfisher

非同期に画像を取得することができるライブラリ

1. PodFile

pod 'Kingfisher'

2. import する

import Kingfisher

3. 使い方(Usage)

imageView.kf.setImage(with: url,
                      placeholder: nil,
                      options: [.transition(ImageTransition.fade(1)), .keepCurrentImageWhileLoading],
                      progressBlock: { (receivedSize, totalSize) in
                        print("receivedSize: \(receivedSize) \ntotalSize: \(totalSize)")
},
                      completionHandler: { image, error, cacheType, imageURL in
                        print("Finished\nimage: \(image), erroe: \(error), cacheType: \(cacheType), imageURL: \(imageURL)")
})

ios-alamofire-demo's People

Watchers

James Cloos avatar kentaro avatar

Forkers

y-okudera

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.