Swift: IBoutlet always returns nil object?

Question!

I have UItableView with Custom UItableViewCell with its nib file.

func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell!
{
    let cell = tableView.dequeueReusableCellWithIdentifier(quoteCellIdentifier, forIndexPath: indexPath) as DynamicTableViewCell

    if (cell == nil)
    {
        println("Not Initialized")
    }
    println(cell)
    println(cell.scenarioLabel)

    return cell
}

Console O/p

<_TtC17Dynamic_Cell_Demo20DynamicTableViewCell: 0xb291a70; baseClass = UITableViewCell; frame = (0 0; 320 44); layer = <CALayer: 0xb291e40>>

For Lable : null

Custom UITableViewCell

class DynamicTableViewCell: UITableViewCell {

@IBOutlet var scenarioLabel: UILabel
@IBOutlet var quoteContentLabel: UILabel    

Connection

enter image description here



Answers

according to @yatheesha answer i am just converting into swift language

var dynCellQuote = UINib(nibName: "DynamicTableViewCell", bundle: nil)

    tableViewForQuotes.registerNib(dynCellQuote, forCellReuseIdentifier: quoteCellIdentifier)


This video can help you solving your question :)
By: admin