UIView.text Showing Up as Nil

  1. 3 years ago

    I am a Swift beginner. I am creating a simple Parse notepad iOS app, for practice. I am trying to access from one class a uitextview created in another class. This leads to an error the uitextview is nil.
    For example, my tableviewcell class is very simple and only has two uiviews connected to it (the outlets are connected properly):

    @IBOutlet weak var titleLabel: UITextView! @IBOutlet weak var descriptionLabel: UITextView! override func awakeFromNib() { titleLabel.text = "Title" descriptionLabel.text = "Description" }
    I then try and access these properties from my detailviewcontroller class, but the error"unexpectedly found nil when unwrapping an optional" comes up, even though my titleLabel and descriptionLabel both have values that are set programmatically.
    detailviewcontroller class (this is in viewdidload):

    let customCell = TableViewCell() var Title = customCell.titleLabel.text let Description = customCell.descriptionLabel.text

    I would really appreciate your help. Thanks.
    *Also please note that my IBOutlets are connected properly

or Sign Up to reply!