Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UITableview搜索栏:筛选数组_Ios_Iphone_Uitableview_Filtering_Uisearchbar - Fatal编程技术网

Ios UITableview搜索栏:筛选数组

Ios UITableview搜索栏:筛选数组,ios,iphone,uitableview,filtering,uisearchbar,Ios,Iphone,Uitableview,Filtering,Uisearchbar,我在为UITableView使用搜索栏筛选器时遇到问题 我正在多个阵列中记录温度数据: NSMutableArray *timeArray; // Array which saves date and time NSMutableArray *tempInside; // saves inside temp NSMutableArray *tempOutside; // saves outside temp NSMutableArray *timeArraySearch; // Array wh

我在为UITableView使用搜索栏筛选器时遇到问题

我正在多个阵列中记录温度数据:

NSMutableArray *timeArray; // Array which saves date and time
NSMutableArray *tempInside; // saves inside temp
NSMutableArray *tempOutside; // saves outside temp
NSMutableArray *timeArraySearch; // Array which saves date and time searched
NSMutableArray *tempInsideSearch; // saves inside temp searched
NSMutableArray *tempOutsideSearch; // saves outside temp searched
所以要显示所有数据,我有一个UITableView。我将时间数组用于
单元格.textlab.text

现在我很难用搜索栏过滤数据。这是我的

filterContentForSearchText
方法:

- (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope
{
    NSPredicate *resultPredicate = [NSPredicate
                                    predicateWithFormat:@"SELF contains[cd] %@",
                                    searchText];

    tempInsideSearch = [tempInside filteredArrayUsingPredicate:resultPredicate];
    tempOutsideSearch = [tempOutside filteredArrayUsingPredicate:resultPredicate];
    timeArraySearch = [timeArray filteredArrayUsingPredicate:resultPredicate];
}
我运行了应用程序,得到了一个空数组异常。然后我再次检查了这个方法,发现tempInsideSearch和tempOutsideSearch是空的是正常的,因为它们不包含像“06:41PM”这样的值

最后,我的问题是:
如何过滤临时数组,使其与时间数组的索引相匹配?

创建一个具有日期/时间、insideTemp、outsideTemp属性的类,将其实例存储到数组中,并在该数组上应用过滤,而不是使用3个不同的数组来存储高度关联的信息…

为什么要使用这么多数组?为什么不使用一个存储所有数据的主数组和一个存储搜索结果的数组?数组中的每个元素都应该是一个有时间的对象或字典,以及两个temp。您好,我不知道如何使用字典。那么,您是指两个数组,例如:
*dataArray,*searchArray
,在这些数组中,我应该将其他数组存储为对象吗?不,不要将其他数组存储在
dataArray
dataArray
应包含一组
NSDictionary
(或自定义对象)。每个字典将存储日期/时间、内部温度和外部温度。这将把每组数据作为一个单元保存在一起。你知道在哪里可以找到简单的NSDictionary说明/教程/示例吗?