Skip to content

In this project I will show some data from a array into a tableView Cell

Notifications You must be signed in to change notification settings

gitMaruf/arrayIntoTableViewCell

Repository files navigation

iOS Apps | Maruf

Show array data into a tableView cell

Our Goal

Its a simplest project to understand tableView Cell

What you will create

We show data into a tableView Cell

What you will learn

  • Declearation a array and accessing its value using key randomly
  • tableView Cell and Show Data into the cell

Let's Learn

Create New Project Tutorial

Drag and Drop a tableView into Storyboard Tutorial

Add a single protype cell to the tableView from Attribute Inspector Tutorial

Select the cell and named it tvCell througn Attribute Inspector Tutorial

Inherite UITableViewDelegate, UITableViewDataSource super class to out ViewController to access data from UI tableView

Create an outlet of out tableView to ViewController Tutorial

Initializ tableView Into Current ViewController default viewDidLoad function as Delegates and DastaSourec

super.viewDidLoad()
tableView.delegate = self
tableView.dataSource = self

Finaly add two function of tableView to return all array data as value into tableView Cell default Label text

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return fruitsArray.count
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "tvCell")!
cell.textLabel?.text = fruitsArray[indexPath.row]
//print(indexPath.row)
return cell
}

Run your project & you will get the result like this Tutorial

Check out the full course and more at Joy www.joyonlineschool.com

About

In this project I will show some data from a array into a tableView Cell

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published