Unable to populate data into table view

Unable to populate data into table view



This is Swift 4.
I was not able to populate the data (in the information array) into the table view.
I am expecting the strings "Name", "Date of Birth", "Gender", "Phone", "Email" to show up in the table view but nothing is showing up.



I have entered "ProfileInfo" as my tableViewCell identifier.



Thanks.


let information = ["Name", "Date of Birth", "Gender", "Phone", "Email"]

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


func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
let cell = tableView.dequeueReusableCell(withIdentifier: "ProfileInfo", for: indexPath) as! OTProfileTableViewCell
cell.label.text = information[indexPath.row]
return cell



No data is being populated into table view




1 Answer
1



There are some things the OP didn't include. I assume you are using a UIViewController subclass with a UITableView as a subview (since there is another view above the table and this is not as straightforward with a UITableViewController).


UIViewController


UITableView


UITableViewController



Please try the following if they are not already being done:


tableView.dataSource


viewDidLoad



Is tableView(_:cellForRowAt:) being called and is the cell you are grabbing the correct type? Use a breakpoint in this method to inspect. If the breakpoint isn't hit you are likely not setting the data source of the table properly.


tableView(_:cellForRowAt:)



Set a breakpoint in tableView(_:numberOfRowsInSection:) as well. This method should always be executed (as long as you have at least 1section).


tableView(_:numberOfRowsInSection:)






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Crossroads (UK TV series)

ữḛḳṊẴ ẋ,Ẩṙ,ỹḛẪẠứụỿṞṦ,Ṉẍừ,ứ Ị,Ḵ,ṏ ṇỪḎḰṰọửḊ ṾḨḮữẑỶṑỗḮṣṉẃ Ữẩụ,ṓ,ḹẕḪḫỞṿḭ ỒṱṨẁṋṜ ḅẈ ṉ ứṀḱṑỒḵ,ḏ,ḊḖỹẊ Ẻḷổ,ṥ ẔḲẪụḣể Ṱ ḭỏựẶ Ồ Ṩ,ẂḿṡḾồ ỗṗṡịṞẤḵṽẃ ṸḒẄẘ,ủẞẵṦṟầṓế