rushisangani / RSSelectionMenu

An elegant selection list or dropdown menu for iOS with single or multiple selections.
MIT License
351 stars 91 forks source link

Get data from Api via closure #23

Closed dev-pankajkainthla closed 6 years ago

dev-pankajkainthla commented 6 years ago

How to pass data through api return. For eg: With every searchText i call an api which return data array and then it refreshes the selection menu. When i try to add the api inside the return function. It shows an error that closure require a return. It is not considering the return from the closure as a return. For eg:

 selectionMenu.showSearchBar(withPlaceHolder: "Search Player", tintColor: UIColor.white.withAlphaComponent(0.3)) { (searchText) -> ([SearchModel]) in

            let parameters = ["term": searchText]
            ThreadStore.shared.search(parameters: parameters) {(success, list) in
               return list as! [SearchModel] .   //(Returning the response from the web service)
           }
        }
rushisangani commented 6 years ago

Hi @dev-pankajkainthla This is just a drop-down/selection menu with the search.

This will not work for API request. You can search through the items that you've passed to the RSSelectionMenu as dataArray.