Use of didSet property observer in custom UITableCell to update TextView
<p>I have a table that displays a list of pupils and their chosen subjects. The pupil's name are displayed as table section headers and each chosen subject is displayed as table rows for each section. I have a simple class to store the pupil's name as a string and their subjects as an array as follows:</p>

<pre><code>import UIKit

class TableText: NSObject {

var name: String

var subject: [String]

init(name: String, subject: [String]) {
    self.name = name
    self.subject = subject

 }

}
</code></pre>

<p>In my custom TableViewCell I have a didSet property observer to track any changes to each pupil's chosen subjects (i.e. I have a textView that the user can click on and modify or change a subject. My didSet is currently as follows:    </p>

<pre><code>var tableText: TableText? {

    didSet {

        let mySubject = myTextView.text
        if ((tableText?.subject.contains(mySubject)) != nil) {          
        }          
    }
}
</code></pre>

<p>My cellForRowAtIndexPath in my TableViewController is as follows:</p>

<pre><code> override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
   let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! myTableViewCell

   cell.delegate = self

    let pupil = tableTexts[indexPath.section]

    cell.myTextView.text = pupil.subject[indexPath.row]

    cell.subject = pupil.subject[indexPath.row]
    cell.name = pupil.name
    print("name: \(cell.name) subject: \(cell.subject)")

    return cell
}
</code></pre>

<p>I'm puzzled at how to take the data from the tableView of each pupil and pupil's subjects and use didSet to set the pupil's name and list of subjects so I can monitor the textViews and update changes to the model as required. I much appreciate any assistance. </p>