1 year ago

#378667

test-img

9to5ios

UITableView with section Filter for json

enter image description here

Expected result

enter image description here I have below json response, but I am unable to filter data keeping section with user_name

{
    "status": 1,
    "result": {
        "Section 0": [
            {
                "id": "240",
                "user_name": "Raman ",

            },
            {
                "id": "241",
                "user_name": "Ram ",

            },
            {
                "id": "243",
                "user_name": "Ramesh ",

            },
            {
                "id": "246",
                "user_name": "Angelia ",
            }
        ],
        "Section 1": [
            {
                "id": "240",
                "user_name": "Rohit ",
      
            },
            {
                "id": "241",
                "user_name": "Robin ",
           
            },
            {
                "id": "246",
                "user_name": "Angelia ",
      
            }
        ],
        "Section 2": [
            {
                "id": "240",
                "user_name": "Raman ",
            
            },
            {
                "id": "242",
                "user_name": "Nick ",

            }
        ]
    },
    "message": ""
}

Code I used for general search in any tableview with normal json

    let searchpredicate:NSPredicate = NSPredicate(format: "SELF CONTAINS[cd] %@",searchText)
 filterdata  = self.responseArray.filter{searchpredicate.evaluate(with: $0)} as! [[String : Any]]
             

xcode

uitableview

predicate

0 Answers

Your Answer

Accepted video resources