菜鸟教程小白 发表于 2022-12-11 22:27:24

iphone - 对象和 NSPredicate


                                            <p><p>在我的应用程序中,我有一个包含大约 12000 个条目的大表。我在tableview上显示它。但是在进行动态搜索时搜索栏太慢了。我读过 NSPredicate 方法比 NSRange 更持久。</p>

<p>这是我的旧代码:</p>

<pre><code>;
listContent = [ initWithArray:];

for (Book *book in listContent)
{

    NSRange range = ;

    if (range.location != NSNotFound)
    {
      ;
    }
}
</code></pre>

<p>我的新代码:</p>

<pre><code> ;
listContent = [ initWithArray:];

NSPredicate *predicate = %@&#34;,searchText];

];
</code></pre>

<p>当我尝试执行此代码时收到此错误:“无法对对象进行正则表达式匹配。”</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>我会做一些更像......</p>

<pre><code>NSPredicate *predicate = %@&#34;,propertyIAmLookingFor,searchText];
</code></pre></p>
                                   
                                                <p style="font-size: 20px;">关于iphone - 对象和 NSPredicate,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/10067014/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/10067014/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: iphone - 对象和 NSPredicate