采用Alamofire + SwiftyJSON + HandyJSON实现一个简单的网络请求及数据解析的小demo:
//
// ViewController.swift
// SwiftGG
//
// Created by mac on 2020/12/19.
//
import UIKit
import SwiftyJSON
import HandyJSON
import Alamofire
class ViewController: UIViewController,UITableViewDelegate,UITableViewDataSource{
@IBOutlet weak var table: UITableView!
var dataArr = [BasicModel]();
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
self.view.backgroundColor = UIColor.white;
self.table.register(UINib(nibName: "MyCell2", bundle: nil), forCellReuseIdentifier: "MyCell2");
self.table.register(UINib(nibName: "MineCell", bundle: nil), forCellReuseIdentifier: "MineCell");
}
@IBAction func btnAction(_ sender: Any)
{
Alamofire.request("http://www.liulongbin.top:3005/api/getlunbo").responseJSON{ [self]