swift tableview 기본 data array 



//

//  MainViewController.swift

//  ai 11

//

//  Created by stayfoolish on 2018. 9. 20..

//  Copyright © 2018년 stayfoolish. All rights reserved.

//


import UIKit


class MainViewController: UIViewController , UITableViewDataSource {


    @IBOutlet weak var tableView: UITableView!

    

    let dataArray = ["1","2","3","4","5","6","7","8","9","10",]

    

    

    override func viewDidLoad() {

        super.viewDidLoad()


        self.tableView.dataSource = self

    }

    

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {

        return self.dataArray.count

    }


    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

        let cell = tableView.dequeueReusableCell(withIdentifier: "numberCell", for: indexPath)

        

        cell.textLabel?.text = self.dataArray[indexPath.row]

        

        return cell

    }

    



}


+ Recent posts