Search code examples
storyboardswift2xcode7.2

xcode 7 unwind does not appear on exit


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!)
    }

    ....
}

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!)
        }
    
        ....
    }