如何做正确的搜索,因为过滤器不起作用

时间:2019-06-14 07:14:07

标签: swift4.2

我用过: var userArray:NSMutableArray = NSMutableArray()

视图确实加载了:

searchTextField.addTarget(self, action: #selector(textFieldDidChange(_:)), for: UIControl.Event.editingChanged)

然后:

extension ChatListController : UITextFieldDelegate{

    @objc func textFieldDidChange(_ textField: UITextField) {

        userArray = userArray.filter { ($0 ["name"] as! String).range(of: textField.text!, options: [.diacriticInsensitive, .caseInsensitive]) != nil }

        print("Filter userArray : ",userArray)
        self.userTable.reloadData()
    }
}

抛出错误:@ $ 0

  

错误:无法下标类型错误或不明确的值

var userArray:NSMutableArray = NSMutableArray()

extension ChatListController : UITextFieldDelegate{

    @objc func textFieldDidChange(_ textField: UITextField) {

        userArray = userArray.filter { ($0 ["name"] as! String).range(of: textField.text!, options: [.diacriticInsensitive, .caseInsensitive]) != nil }

        print("Filter userArray : ",userArray)
        self.userTable.reloadData()
    }
}

无法下标错误类型或不明确类型的值

1 个答案:

答案 0 :(得分:0)

@raj使用此代码

$select = //myquery

    $groups = array();
    $group50 = array();

    while($row1 = mysql_fetch_assoc($select)){
        if($row1['total_coupon'] == 50)
        {
            array_push($group50, $row1['kupon_id']);
        }
        else
        {
            if(count($group50) > 0)
            {
                $minKuponId = min($group50);
                $maxKuponId = max($group50);

                array_push($groupss, $minKuponId,$maxKuponId);

                unset($group50);
                $group50 = array();
            }
            //array_push($groups, $row1['kupon_id']);
        }                                                                   
    }

    foreach($groups as $group)
    {
    echo $minKuponId;
    echo $maxKuponId;             
    }