Issue with handling cell re-iteration in Swift
<p>I have a very interesting case in which I have two <code>UITableViews</code>.  The primary <code>TableView</code> is a <code>UITableViewController</code>.  Each cell is made up of three parts.  The <code>Header</code> which display a title, the <code>Body</code> which acts as an accordion when you select your <code>cell</code>, and finally a <code>UITableView</code> that uses a custom <code>Cell Identifier</code> but uses the same delegate as the <code>UITableViewController</code> or <code>parent</code>.  </p>

<p>Now the problem I am having is, when the user scrolls around, all the titles get jumbled up for the <code>parent uitableview</code> and as well as the <code>child uitableview</code> and I know it has to do with my <code>dequeueReusableCellWithIdentifier</code>.  </p>

<p><a href="https://i.stack.imgur.com/omrcO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/omrcO.png" alt="jumbled text"></a></p>

<p>Where the word <code>developer</code> is, that is the parent <code>tableview</code>.  The jumbled text <code>that is a sub uitableview</code>.  I'm looking for some guidance on the best possible solution to solve this problem.  Here is what I am doing:</p>

<pre><code>override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
        if tableView == self.tableView {
            // #  Adjust profile picture
        //cell.headerView.profileImage.frame = CGRectMake(0,0, 50, 50)
        cell.headerView.profileImage.image = UIImage(named: "avatar-ph.jpg")
        cell.headerView.profileImage.layer.cornerRadius = 
             cell.headerView.profileImage.frame.size.width / 2

        cell.headerView.profileImage.clipsToBounds = true

         ... do stuff
            cell.detailView.innertableView.dataSource = self

            // This is needed for dequeueing to succeed:
            cell.detailView.innertableView.registerClass(SingleOrderTableViewCell.self, forCellReuseIdentifier: "SingleOrderTableViewCell");

            cell.detailView.innertableView.reloadData()
        }
        else {
// [B] INNER TABLE VIEW
            let cell = tableView.dequeueReusableCellWithIdentifier("SingleOrderTableViewCell", forIndexPath: indexPath) as! SingleOrderTableViewCell


            // #  Setup our data to display
        // ## Title
        cell.title = UITextField (frame:CGRectMake(75, 5, 300, 20));
        cell.title.font = UIFont(name: "System Light", size: 10);
        cell.title.text = drinkName;

        cell.title.textColor = UIColor(netHex:0x362C6B);
        // ## qty
        cell.qty = UITextField (frame:CGRectMake(75, 22.5, 300, 20));
        cell.qty.font = UIFont(name: "System Light", size: 10);
        cell.qty.text = "Qty: " + qty;
        cell.qty.textColor = UIColor.grayColor();


        // #  Add to subframe
        cell.addSubview(cell.title);
        cell.addSubview(cell.qty);
           return cell
        }
}
</code></pre>

<p>The code above show cases how I handle the distinguishing of the two <code>tableviews</code> and set the corresponding cells to their correct <code>tableview</code>.</p>

<p>Now another thing to note that the information that is populated here is based off an object returned from the server.  So my thought was, it is working correctly; but the <code>indexPath.row</code> is off from the actual associated <code>cell</code>.</p>

<p>Any thoughts or suggestions?</p>