The short version is:
Do the values of a VC's variables stay in tact during the modal presentation and dismissal of another VC? When the second VC is dismissed, are the original VC's variables still equal to their last values?
Details, If Needed
I have a viewController where a table cell is selected. The contents of that cell are then pulled out and passed onto an editor viewController like this:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
//Segue to mainVC editor, for editing action
if (segue.identifier == "modalToEditor") && passingEdit == true {
//Assign selection to a variable 'currentCell'
let indexPath = tableView.indexPathForSelectedRow;
let currentCell = tableView.cellForRowAtIndexPath(indexPath!) as! CustomTableViewCell;
//Set cell text into variables to pass to editor
let cellNameForEdit = currentCell.nameLabel!.text
let cellDescForEdit = currentCell.descLabel.text
//Pass values to EditorView
let editorVC = segue.destinationViewController as! EditorView;
editorVC.namePassed = cellNameForEdit
editorVC.descPassed = cellDescForEdit
editorVC.indexOfTap = indexPath
editorVC.currentListEntity = currentListEntity
Now, in that second/editor viewController, the user may tap a button asking to move the cell. The "move screen" is a different/third VC. What I want to know is, can I dismiss the editor and expect the original VC to remember the last cell chosen?
- If it will remember, then I'd assume I could then pass it onto the the third/move VC.
- If the original VC cell variable won't still hold that last cell, I'd have to figure out a way to make it remember! Global variable maybe?
Appending an edit to show the cellForRowAtIndexPath
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
//Setup variables
let cellIdentifier = "BasicCell"
let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier, forIndexPath: indexPath) as! CustomTableViewCell
//Make sure the row heights adjust properly
tableView.rowHeight = UITableViewAutomaticDimension
tableView.estimatedRowHeight = 80.0
//Create normal cells except when last cell
if indexPath.row < taskList_Cntxt.count {
let task = taskList_Cntxt[indexPath.row]
//Create table cell with values from Core Data attribute lists
cell.nameLabel!.text = task.valueForKey("name") as? String
cell.descLabel!.text = task.valueForKey("desc") as? String
//Related to running TaskActions: Empty block function passed from custom cell VC
cell.doWork = {
() -> Void in
self.doStuff(cell)
}
}