Friday, August 19, 2022
HomeiOS Developmentios - Why this error? Can't convert worth of kind 'String' to...

ios – Why this error? Can’t convert worth of kind ‘String’ to anticipated argument kind ‘(String.Ingredient) throws -> Bool’ (aka ‘(Character) throws -> Bool’)


I’m constructing a Russian – Tajik Translator for iOS. The next are the category and construction I’ve created to populate my TableView.

Nonetheless, I’m receiving this error:

Can’t convert worth of kind String to anticipated argument kind (String.Ingredient) throws -> Bool (aka (Character) throws -> Bool)

May somebody, please assist?

class ViewController: UIViewController {
    let searchController = UISearchController()
    var phrase:[Dictionary] = Dictionary.dictionary
    var filteredWord:[Dictionary] = []
    var searchBarIsEmpty: Bool {
        guard let searchingText = searchController.searchBar.textual content else {return false}
        return searchingText.isEmpty
    var isFiltering: Bool {
        searchController.isActive && !searchBarIsEmpty
    @IBOutlet weak var dictionaryTableView: UITableView!
    override func viewDidLoad() {
        //Nagivation Controller
        navigationController?.navigationBar.prefersLargeTitles = true
        navigationItem.searchController = searchController
        //Search Controller
        searchController.searchBar.placeholder = "Поиск слова"
        searchController.definesPresentationContext = true
        searchController.obscuresBackgroundDuringPresentation = false
        searchController.searchResultsUpdater = self
        title = "Русско-Таджикский"
        //DictionaryTableView Delegates & Strategies
        dictionaryTableView.delegate = self
        dictionaryTableView.dataSource = self

extension ViewController: UITableViewDelegate, UITableViewDataSource {
    func tableView(_ tableView: UITableView, numberOfRowsInSection part: Int) -> Int {
        if isFiltering {
            return filteredWord.rely
        } else {
            return phrase.rely
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        if isFiltering {
            let wordCell = dictionaryTableView.dequeueReusableCell(withIdentifier: "WordTableViewCell", for: indexPath) as! WordTableViewCell
            wordCell.wordLabel.textual content = filteredWord[indexPath.row].phrase
            return wordCell
        } else {
            let wordCell = dictionaryTableView.dequeueReusableCell(withIdentifier: "WordTableViewCell", for: indexPath) as! WordTableViewCell
            wordCell.wordLabel.textual content = phrase[indexPath.row].phrase
            return wordCell
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        dictionaryTableView.deselectRow(at: indexPath, animated: true)
        if let meaningVC = storyboard?.instantiateViewController(withIdentifier: "MeaningViewController") as? MeaningViewController {
            meaningVC.phrase = phrase[indexPath.row].phrase
            meaningVC.which means = phrase[indexPath.row].which means
            current(meaningVC, animated: true)

extension ViewController: UISearchResultsUpdating {

    func updateSearchResults(for searchController: UISearchController) {
        filteringDictionary(searchController.searchBar.textual content!)
    func filteringDictionary(_ searchText: String) {
        filteredWord = phrase.filter({ (searchingWord: Dictionary) in
            return searchingWord.phrase.lowercased().accommodates(the place: searchText.lowercased())

    struct Dictionary {
    let phrase: String
    let which means: String
    static let dictionary: [Dictionary] = [
.init(word: "абажур", meaning: "м абажур, сарпӯши чароғ, қуббаи чароғ, болопӯшаки лампа")]



Most Popular

Recent Comments