0

I know there are a lot of Stack Overflow questions like this out there, but none of the answers I can find work for me. I am using a custom UITableViewCell class called chillerCell. Here is its code:

import UIKit

class chillerCell: UITableViewCell {

    @IBOutlet weak var iconLabel: UILabel!
    @IBOutlet weak var boldLabel: UILabel!
    @IBOutlet weak var italicLabel: UILabel!

    func configureCellWithEvent(event: Event){
        boldLabel.text = "\(event.eventName)"
        italicLabel.text = "\(event.eventDescription)"
    }
}

I get the Thread 1 runtime error on the line boldLabel.text = "\(event.eventName)"

I made my own Event class, and yes, event.eventName and event.eventDescription are of type String and are not Nil.

Edit: I forgot to mention, my boldLabel and italicLabel are not plain text, but attributed text.

Jonathan Allen Grant
  • 3,408
  • 6
  • 30
  • 53
  • Can you give us more detail of the runtime error? Have you checked that your IBOutlet is correctly linked? – Ali Beadle Jul 08 '15 at 20:19
  • Yes my storyboard is connected properly. I even disconnected the outlets and reconnected them. – Jonathan Allen Grant Jul 08 '15 at 20:22
  • Very strange. Can you check boldLabel in the debugger to ensure it is not nil. If not try changing another property - e.g. BoldLabel.hidden = true. Also try swapping boldLabel and italicLabel to see if it is specific to boldLabel. – Ali Beadle Jul 09 '15 at 05:06
  • boldLabel is nil. However, it is definitely connected to the storyboard – Jonathan Allen Grant Jul 10 '15 at 16:41
  • OK, but that sounds like the problem. Take a look at [this SO Question](http://stackoverflow.com/questions/6223457/reasons-for-an-iboutlet-to-be-nil) or [this one](http://stackoverflow.com/questions/29321383/iboutlet-is-nil-but-it-is-connected-in-storyboard-swift) to find out why a linked Outlet may still be nil. – Ali Beadle Jul 10 '15 at 17:11

2 Answers2

0

Try this, it would work if event object having eventName & eventDescription as String:

func configureCellWithEvent(event: Event){
    var attributedString = NSMutableAttributedString(string:"(event.eventName)") and boldLabel.text = attributedString
    boldLabel.text = attributedString
    italicLabel.text = attributedString
}
Dilip Lilaramani
  • 1,126
  • 13
  • 28
0

Delete the labels and create a others again, thats work for me.

josedlujan
  • 5,357
  • 2
  • 27
  • 49