xcode 7 unwind does not appear on exit

495 views Asked by At

I am using Xcode 7. I wrote unwind function in view A. I want to return from view B to view A. When i drag my button with ctrl on exit, no any unwind function appears. When i right click on exit, it is empty. How can i resolve it? or can i set unwind programmatically?

Here is my unwind function:

@IBAction func unwindToProductList(sender: UIStoryboardSegue) {
    print("unwindToProductList called")
}

enter image description here

Edit:

I think i found the issue, but can't understand why xcode acts like that. At the beginning of my viewcontroller i have this code lines:

import UIKit

extension ProductListViewController: UISearchResultsUpdating {
    func updateSearchResultsForSearchController(searchController: UISearchController) {
        filterContentForSearchText(searchController.searchBar.text!)
    }
}

class ProductListViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
.....
}

when i comment my extension, exit see my unwind function, but if uncomment my extension, exit does not see my unwind function again, did i write extension at the wrong place?

Solution:

I fixed my issue by removing extension from the beginning of my code and implemented it in the view controller, after it Exit button start seeing my unwind function:

class ProductListViewController: UIViewController, UITableViewDataSource, UITableViewDelegate, UISearchResultsUpdating {

    func updateSearchResultsForSearchController(searchController: UISearchController) {
        filterContentForSearchText(searchController.searchBar.text!)
    }

    ....
}
2

There are 2 answers

0
kakajan On BEST ANSWER

I fixed my issue by removing extension from the beginning of my code and implemented it in the view controller, after it Exit button start seeing my unwind function:

class ProductListViewController: UIViewController, UITableViewDataSource, UITableViewDelegate, UISearchResultsUpdating {

    func updateSearchResultsForSearchController(searchController: UISearchController) {
        filterContentForSearchText(searchController.searchBar.text!)
    }

    ....
}
2
Alain T. On

Could it be that your class for view controller "A" in IB is not assigned to the corresponding UIViewController class you defined ? This would prevent the editor/compiler from seeing the IBAction because it won't find any IB view controller that links to your class.