here's the code:
import UIKit
class SliderMenuTableViewController: UITableViewController {
var tableArray = [String]()
override func viewDidLoad() {
super.viewDidLoad()
// Uncomment the following line to preserve selection between presentations
// self.clearsSelectionOnViewWillAppear = false
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem()
let age: String
age = String(LoginViewController.AGE)
let Profile = LoginViewController.NAME! + ", " + age
tableArray = [Profile,"Second","Third","Fourth","Logout"]
}
// table view delegate method
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell = tableView.dequeueReusableCellWithIdentifier(tableArray[indexPath.row], forIndexPath: indexPath) as UITableViewCell
cell.textLabel?.text = tableArray[indexPath.row]
if cell.textLabel?.text == tableArray[0] {
cell.imageView?.frame = CGRectMake(10, 10, 50, 50)
cell.imageView!.layer.borderWidth = 1
cell.imageView!.layer.masksToBounds = false
cell.imageView!.layer.borderColor = UIColor.blackColor().CGColor
cell.imageView!.layer.cornerRadius = cell.imageView!.frame.width/2
cell.imageView!.clipsToBounds = true
cell.imageView?.image = LoginViewController.AVATAR
}
return cell
}
Error occured:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier Viktor, Optional(29) - must register a nib or a class for the identifier or connect a prototype cell in a storyboard
I understand that I have to identifier the cell, how to do this from code cause the variable 'Profile' that in my tableArray
isn't static and I can't identifier it from storyboard?