Giter VIP home page Giter VIP logo

sfh03031 / sfnetworkmanager Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 0.0 376 KB

A network request framework based on Moya and HandyJSON, which can return an object model that follows the HandyJSON protocol and can be flexibly customized according to needs.(zh: 基于Moya、HandyJSON封装的网络请求工具类,返回遵循HandyJSON协议的对象模型,可根据需求灵活自定义。)

License: MIT License

Ruby 6.86% Swift 93.14%

sfnetworkmanager's Introduction

SFNetworkManager

CI Status Version License Platform

Introduction

A network request framework based on Moya and HandyJSON, which can return an object model that follows the HandyJSON protocol and can be flexibly customized according to needs.I have written several examples to demonstrate usage, and the object model can be customized according to requirements by following the HandyJSON protocol.

(zh: 基于Moya、HandyJSON的网络请求框架,可返回遵循HandyJSON协议的对象模型,可根据需求灵活自定义。写了几个例子展示用法,对象模型可按需求进行自定义,只需遵循HandyJSON协议即可。)

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

import UIKit
import HandyJSON
import SFNetworkManager

class BallModel: HandyJSON {
    var ballType: String?
    var roomId: String?
    var userId: String?
    var viewertoken: String?
    
    required init() {}
}

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = .white
            
        SFNetworkManager.request(target: APIService.yourRequestName(parameters: ["positionKey": "0"]), 
                                 modelType: BallModel.self,
                                 isLoading: true,
                                 progress: { progress in
            print("进度: \(progress)")
        }) { msg, model in
            print("msg: \(String(describing: msg))")
            print(model?.ballType as Any)
            print(model?.roomId as Any)
            print(model?.userId as Any)
            print(model?.viewertoken as Any)
        } failure: { error in
            print(error?.debugDescription as Any)
        }

    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

}

you can see the code in the Example Project.

Requirements

  • iOS 12.0 or later
  • Swift 5.9.2
  • Xcode 15.1

Installation

SFNetworkManager is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'SFNetworkManager'

If you want to use the latest features of SFNetworkManager use normal external source dependencies.

pod 'SFNetworkManager', :git => 'https://github.com/Sfh03031/SFNetworkManager.git'

Change log

2024.07.31, 0.1.3

  • fix bug and update readme(zh: 修复bug、更新readme)

2024.07.12, 0.1.2

  • code optimize, add new indicatorView(zh: 代码优化,新增指示器)

2024.04.16, 0.1.1

  • update plugin(zh: 更新插件)

2024.03.12, 0.1.0

  • Initial version(zh: 初始版本)

Author

Sfh03031, [email protected]

License

SFNetworkManager is available under the MIT license. See the LICENSE file for more info.

sfnetworkmanager's People

Stargazers

 avatar uxiu.me avatar babayaga avatar

Watchers

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