A Table What?

How to create a table view for your data

Kenji Daniel Akiba
4 min readOct 29, 2021
From apple’s documentation, https://developer.apple.com/

That’s right, a tableView! Whether you have noticed or not a table view is part of an app that you will or have seen when you open up an app or when you get into a website and there are some forms you will fill in sometime in your life. When it comes to creating one there are ones living in your settings of your phone, does not matter iOS or Android. It. Is. EVERYwhere. By definition: a view that presents data using rows in a single column. Each row in the table contains one piece of your app’s content. For example, the Contacts app displays the name of each contact in a separate row and in each section has a header that you may or may not want to show.

Within the next few minutes I will show you how can you implement these table views onto your app or how is it created and housed.

Here for an example you can have it to where you will be able to edit each row and what is called a ‘cell’, a cell is what contains your content when you define it on your storyboard or in code. Cells provide the visual representation of your table’s rows. You can however add more rows to a TableView, but why would you when you can categorize each individually like for example the contacts each alphabetically!

How would it be implemented?

When creating a table view you might want to take a step back and consider: Is this something I want in an app or do I want a certain type of input form to gather feedback? Look at figure 1a for an example, it has a name textfield; a last name textfield; an age textfield, and a email textfield.

figure 1a

Ok it might not have an age textfield to input, but you get the point. Each and individual ‘cell’ or row has content so that a user can type or enter whether it would be by keyboard or a scroll wheel of options.

Step 1.)You can just use the default View Controller that it comes with.(just for the purpose of this tutorial.)

Step 2.) You may be tempted to add a navigational controller with a tableview controller that it comes with, or a table view controller itself, but for more greater customizability it is best to drag a table view from the library and drag a table view cell onto your view controller.

Step 3.) Getting into the nitty gritty code, my favourite part of the lesson.(sarcasm)

you might want to refactor the class into a ‘UITableViewController’ in order for it to actually talk with your controller and get it into view and customize it.

Might I suggest to change it’s identity to what ever you name your view controller to and almost ALOT of developers forget to and bang their heads on the wall. I had to learn it the hard way.

Last thing you want to do is add some datasource and delegates in order to display what it need. For example it is like turn on a car engine, when you insert your key to start — or in some cases a button to push to start, in turn the engine inside tells the car it is time to run. Look at figure 2a. Right where it says UITableViewController add two protocols next to it, “UITableViewDelegate and UITableViewDataSource”. When the error comes up saying it needs stubs go right ahead and click fix.

figure 2a
figure 3a

Conclusion

That’s it! That is how you would implement and show data to a user and/or gain feedback within a form on an app. Thoughts? Learning about what a table view is and show forth what I taught at first was excruciating — reason being was mainly because of xCode itself having to constantly restarting the software and some code just would not communicate from within. Constraints would not just agree on certain measurements.

--

--

Kenji Daniel Akiba

App developer, iOS; PC and avid comic enthusiast; always a student