table view

table viewでインド人に作ってもらった。

import UIKit

class CategoryListVC: UIViewController,UITableViewDataSource,UITableViewDelegate {

    //MARK:- IBOutlets
    @IBOutlet var tblCategoryList: UITableView!
    
    //MARK:- Variables
    var arrCategoryListData = NSMutableArray()
   
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.setupUI()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    //MARK:- SetUp UI
    func setupUI() -> Void {
        
        self.tblCategoryList.delegate = self
        self.tblCategoryList.dataSource = self
        
        self.arrCategoryListData = [["Name":"Motors"],["Name":"Fashion"],["Name":"Electronics"],["Name":"Collectibles & Art"],["Name":"Home & Garden"],["Name":"Sporting Goods"],["Name":"Toys & Hobbies"],["Name":"Bussiness & Industrial"],["Name":"Music"]]
        self.tblCategoryList.reloadData()
        
    }
    
    
    //MARK:- UITableView Related Methods
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 50
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return self.arrCategoryListData.count
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        
        let cell = tableView.dequeueReusableCell(withIdentifier: "TableViewFOrCategoryListing", for: indexPath) as! TableViewFOrCategoryListing
        
        guard let dictCell = self.arrCategoryListData.object(at: indexPath.row) as? NSDictionary else {
            return cell
        }
        
        if let price = dictCell.value(forKey: "Name") {
            cell.lblCategoryName.text = String(describing: price)
        }
        
        return cell
    }
    
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        tableView.deselectRow(at: indexPath, animated: true)
        
        guard let dictCell = self.arrCategoryListData.object(at: indexPath.row) as? NSDictionary else {
            return
        }
        
        if let objView = self.storyboard?.instantiateViewController(withIdentifier: "ViewController") as? ViewController {
            
            objView.dictForCategoryDetails = dictCell
            self.navigationController?.pushViewController(objView, animated: true)
        }
        
    }
    

}

class TableViewFOrCategoryListing: UITableViewCell {
    
    @IBOutlet var lblCategoryName: UILabel!
    
}

やべー、俺も早く頑張らないと。。