gpt4 book ai didi

objective-c - 如何限制 iOS 中 NSInteger 的最大数量?

转载 作者:行者123 更新时间:2023-11-28 22:58:49 25 4
gpt4 key购买 nike

我有一张表,用于在 iOS 中使用 UISearchBar 显示搜索数据。

当我用关键字搜索时,我将数据检索到 NSMutableArray 中。NSMutableArray 中有很多数据。我只想在 tableView 中显示大约 20 个数据。通常我使用数据在 tableview 中显示,

return [self.myArrayData count];

它显示了 NSMutableArray 的全部数据。我想限制在 tableView 中显示的数据数。

我如何限制该数据计数?感谢您的帮助。

最佳答案

NSInteger count = [self.myArrayData count];
if (count > 20) return 20;
return count;

关于objective-c - 如何限制 iOS 中 NSInteger 的最大数量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10333466/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com