搜索栏未过滤

时间:2018-01-31 05:16:21

标签: ios swift

此代码我用于搜索,但它不适合我。当我在搜索栏中输入内容时,记录不会被过滤? 还有其他办法吗?

if(isSearching == true){
    let contactDict :NSDictionary = self.filteredArray?.object(at: indexPath.row) as! NSDictionary;
    let strArray :NSArray = contactDict.object(forKey: kName) as! NSArray
    nameString = strArray.componentsJoined(by: "").mutableCopy() as! NSMutableString
    companyNameString = (contactDict.object(forKey: kCompanyName) as AnyObject).object(at: 0) as? NSString;
    designationString = (contactDict.object(forKey: kDesignation) as AnyObject).object(at: 0) as? NSString;
    profileImage = contactDict.object(forKey: kProfilePic) as? UIImage;
    connectStatus = contactDict.value(forKey: kLinkStatus) as? NSString;

    if(profileImage?.accessibilityIdentifier == "Img_placeholder"){
        profileImage = nil;
    }

    //isFav = contactDict.object(forKey: kIsFav) as! Bool;
    let favArry:NSArray = contactDict.value(forKey: kIsFav) as! NSArray
    let favStr = favArry.componentsJoined(by: "")

    //isFav = favStr as Bool
    isFav = NSString(string:favStr).boolValue

    print("is fav is",isFav)

    if(connectStatus == nil){
       // cell.linkButton.setImage(UIImage(named:"link_none"), for: UIControlState())
       cell.linkButton.setImage(UIImage(named:"link1"), for: UIControlState())

       cell.linkStatus = nil;
     }
     else if(connectStatus == "1"){
        cell.linkButton.setImage(UIImage(named:"link_backward"), for: UIControlState())
        cell.linkStatus = "1"
     }
     else if(connectStatus == "2"){
        cell.linkButton.setImage(UIImage(named:"link_both_ways"), for: UIControlState())
        cell.linkStatus = "2"
     }
     else if(connectStatus == "3"){
         cell.linkButton.setImage(UIImage(named:"link_forward"), for: UIControlState())
         cell.linkStatus = "3"
      }
 }

1 个答案:

答案 0 :(得分:-1)

[
    { id: 3, name: 'Tim Jones',  age: 60 },
    { id: 4, name: 'Blake Owen', age: 78 }
]