This is my code creating a UITableView using storyboard hten i update my ViewController.swift file like this. Its working fine in when i run it in simulator, but i an facing an error at the time of i run it in my device
ViewController.swift
import UIKit
class ViewController: UIViewController,UITableViewDelegate,UITableViewDataSource {
@IBOutlet weak var tableViewObject: UITableView!
var foodNames: [String] = ["Food1","Food2","Food3","Food4","Food5","Food6","Food7","Food8"];
var foodImages: [String] = ["image1", "image2", "image3","image4","image5","image6","image7","image8"];
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int
{
return foodNames.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
let cell:UITableViewCell=UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "mycell")
cell.textLabel.text = foodNames[indexPath.row]
var image : UIImage = UIImage(named: foodImages[indexPath.row])!
cell.imageView.image = image
cell.imageView.sizeToFit()
return cell
}
override func viewDidLoad()
{
super.viewDidLoad()
}
}
I am facing this error shown below