I’m trying to connect a UITextView in a Nib to the ViewController - it’s displayed as part of a UITableViewCell.
I can’t work out how I can pass the text inserted by the user to the ViewController when a button is pressed.
Below is the code for the nib, but what do I put in the View Controller? (All I need to do is get the text as a variable). I’ve tried to use let answerText = Answer.textView.text but get an error saying 'Instance Member ‘textView’ cannot be used on type ‘Answer’.
Thanks
Claire
import UIKit
class Answer: UITableViewCell, UITextViewDelegate {
@IBOutlet weak var questionLabel: UILabel!
@IBOutlet weak var textView: UITextView!
override func awakeFromNib() {
super.awakeFromNib()
let selectedView = UIView(frame: CGRect.zero)
selectedView.backgroundColor = UIColor(red: 228/255, green: 0, blue: 58/255, alpha: 0.5)
selectedBackgroundView = selectedView
questionLabel.numberOfLines = 0
self.textView.becomeFirstResponder()
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}`