0

there are my two array and I have User Class that has Name and user image

var users = Array<User>()
var filteredTableData = Array<User>()

   override func viewDidLoad() {
    super.viewDidLoad()


    // Reload the table

    self.resultSearchController = ({

        let controller = UISearchController(searchResultsController: nil)
        controller.searchResultsUpdater = self
        controller.dimsBackgroundDuringPresentation = false
        controller.searchBar.sizeToFit()

        self.tableView.tableHeaderView = controller.searchBar

        return controller
    })()



        for var i = 0 ; i < Dataholder.sharedInstance(self.view).users.count; ++i
        {

            users.append(Dataholder.sharedInstance(self.view).users[i])
        }
   }

and then

   func updateSearchResultsForSearchController(searchController: UISearchController)
    {
     filteredTableData.removeAll(keepCapacity: false)

    let searchPredicate = NSPredicate(format: "Name CONTAINS[c] %@", searchController.searchBar.text)
    println(searchPredicate)
      let array = (users as    NSArray).filteredArrayUsingPredicate(searchPredicate) as! [User]
    filteredTableData = array

        self.tableView.reloadData()
}

and ı get that error

NSForwarding: warning: object 0x7fe08604e730 of class 'Project.User' does not implement methodSignatureForSelector: -- trouble ahead Unrecognized selector -[Project.User valueForKey:]

I want to return my user object not just name there are many example on internet but only search any text, I want to search by name but return filteredTableData like user objects

idris yıldız
  • 2,097
  • 20
  • 22

0 Answers0