Coder Social home page Coder Social logo

hasyapanchasara / alamofire-api-calling Goto Github PK

View Code? Open in Web Editor NEW
9.0 3.0 4.0 145 KB

Alamofire API Calling Example

Swift 96.89% Ruby 0.11% Objective-C 0.30% Shell 2.70%
alamofire ios swift swift4 reachability api objective-c alamofireimage alamofire-swiftyjson alamofire-extension

alamofire-api-calling's Introduction

Alamofire-API-Calling

Alamofire API Calling Example

  • Alamofire pod and implementation
  • Swift 4
  • GLOBAL singleton class
  • API calling MVC structure
  • GET and POST method
  • Header parameter provision
  • Retry count
  • Completion handler
  • Query Parameters
  • Body Parameters
  • Reachability POD and implementation
  • Easy integration with Objective C

POD commands and guideline

(1) Open terminal and go to location of your xcodeproj

(2) In terminal fire this command -> $pod init

(3) Open podfile

(4) Add below line of code befor 'end'

pod 'Alamofire'
pod 'ReachabilitySwift', '~> 3'

(5) Save and close podfile

(6) In terminal fire this command -> $pod install

API Calling Swift 4 code

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
       
        self.API_Formation_Function("[email protected]", password: "password12345")
    }

    
    func API_Formation_Function(_ userName : String , password : String) {
       
        EMReqeustManager.sharedInstance.apiLogin(userName, password: password) {
            (feedResponse) -> Void in
            
                // Show your progress HUD here
            
            if let downloadError = feedResponse.error{

                // Hide progress HUD here and show error if comes
            
            } else {
                if let dictionary = feedResponse.responseDict as? Dictionary<String, AnyObject>{
            
                    // Hide progress HUD here and show response
                    
                    let responseModel = EMResponseModel.init(jsonDict: dictionary)
                    
                    print(responseModel)
                    
                }
            }
        }
       
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
}

alamofire-api-calling's People

Contributors

hasyabv avatar hasyapanchasara avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  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.