Good morning .. I have the class person
class pessoa
{
var nome : String = “”;
var idade : Int = 0;
var foto : UIImage!;
}
extension pessoa
{
class func Gerar_Registros(pQtd : Int) -> Array<pessoa>
{
var vpessoa : pessoa;
for A in 1...pQtd
{
vpessoa = pessoa();
vpessoa.nome = “Nome..: \(A)”;
vpessoa.idade = A;
vpessoa.foto = UIImage(named : “foto1”);
}
}
}
Normally to make the search bar work I use this variable
var Array_Name = ["Mary", "Jose", "John", "Antonio"],
var Array_search: [String]!;
> Class vc_01 : UIViewController
> {
> var Array_Nome = [“Maria”,”Jose”,”João”,”Antonio”];
> var Array_Busca : [String]!;
> override func viewDidLoad()
> {
> super.viewDidLoad()
>
> Array_Busca = Array_Nome;
> }
>
> func tableView(_ tableView : UITableView, numberOfRowsInSection
> Numeros_Linhas_na_Secao : Int)-> Int // Esta Metodo faz parte do
> UITableViewDataSource
> {
> return self.Array_Busca.count;
> }
>
>
>
>
> func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
>
> let cell = tableView.dequeueReusableCell(withIdentifier: "cel01") as! cel01
>
> cell.ContactNameLabel.text! = Array_Busca[indexPath.row]
>
> cell.selectionStyle = .none
>
> return cell
>
> }
>
> func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String)
> {
> Array_Busca = searchText.isEmpty ? Array_Nome : Array_Nome.filter { (item: String) -> Bool in
>
> return item.range(of: searchText, options: .caseInsensitive, range: nil, locale: nil) != nil
> }
>
> tableView.reloadData()
> }
>
> func searchBarTextDidBeginEditing(_ searchBar: UISearchBar) {
> self.searchBar.showsCancelButton = true
> }
>
>
> func searchBarCancelButtonClicked(_ searchBar: UISearchBar) {
> searchBar.showsCancelButton = false
> searchBar.text = ""
> searchBar.resignFirstResponder()
> }
> }
I'm already trying for several days to make the above code run with the person class. Does anyone know how to do ??? Could you tell me how ?? Thanks in advance for your attention :) Hugs:)