美文网首页
IOS筛选搜索

IOS筛选搜索

作者: 蜗牛1992 | 来源:发表于2016-09-03 22:05 被阅读209次
-(void)SearchAction:(UITextField*)pTextField{
    
    NSInteger iLength = pTextField.text.length;
    if(iLength == 0){
        m_pFriendListArray = m_pTempArray;
        [m_pTableView reloadData];
        
    }
    if (pTextField.text.length > 0) {
        
        NSString *regex = [NSString stringWithFormat:@"pstrName LIKE[cd] '*%@*'",pTextField.text];
        NSPredicate *predicate = [NSPredicate predicateWithFormat:regex];
        m_pFriendListArray = [[NSMutableArray alloc]initWithArray:[m_pTempArray filteredArrayUsingPredicate:predicate]];
        
        [m_pTableView reloadData];
    }else{
        m_pFriendListArray = m_pTempArray;
        [m_pTableView reloadData];
        
    }
    
}

相关文章

网友评论

      本文标题:IOS筛选搜索

      本文链接:https://www.haomeiwen.com/subject/lnqlettx.html