I made basic tableView
inside ViewController
and while loading I get
fatal error: unexpectedly found nil while unwrapping an Optional value
Which points to tableView.delegate = self
(by points to I mean this line is highlighted in green colour in Xcode). Here's full code:import UIKit
import UIKit
class FAQViewController: UIViewController, UITableViewDataSource, UITableViewDelegate, UINavigationControllerDelegate, SWRevealViewControllerDelegate {
@IBOutlet var menuButton: UIBarButtonItem!
@IBOutlet var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
tableView.delegate = self
tableView.dataSource = self
if revealViewController() != nil {
//I have SWRevealController that slides viewController from Left side
}
}
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 5
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("FAQ") as! FAQTableViewCell
cell.questionLabel.text = "Here goes Question"
cell.answearLabel.text = "This is answear"
return cell
}
}