Ios 我正在使用NSPredicate筛选多级NSArray。我正在尝试使用谓词筛选数组的第三个子数组,但我得到了这个结果

Ios 我正在使用NSPredicate筛选多级NSArray。我正在尝试使用谓词筛选数组的第三个子数组,但我得到了这个结果,ios,objective-c,multidimensional-array,filter,nspredicate,Ios,Objective C,Multidimensional Array,Filter,Nspredicate,无法分析格式字符串“json.option\u titles.ANY.options.ANY.jobID==%@ 虽然我可以使用for循环,但我可能有一个选项标题长度很长,所以这不好。是否可以使用nspredicate? 这是我的样本数据 ( { dept = 1194; id = 2299; job = 22048; json = { name = tester; "option_titles" = (

无法分析格式字符串“json.option\u titles.ANY.options.ANY.jobID==%@

虽然我可以使用for循环,但我可能有一个选项标题长度很长,所以这不好。是否可以使用nspredicate? 这是我的样本数据

(
{
    dept = 1194;
    id = 2299;
    job = 22048;
    json =     {
        name = tester;
        "option_titles" =         (
                        {
                "custom_option_title" = "";
                "financing_option" = "";
                options =                 (
                                        {
                        hours = "2.00";
                        jobID = 22048;
                        optionDesc = "Sample Description";
                    },
                                        {
                        hours = "2.00";
                        jobID = 22048;
                        optionDesc = "Sample Description";
                    },
                );

            }
        );
        "system_observations" = "";
    };
    name = tester;
    "sort_order" = 178;
    "system_observations" = "";
},
{
    dept = 1195;
    id = 2300;
    job = 22000;
    json =     {
        name = tester second;
        "option_titles" =         (
                        {
                "custom_option_title" = "title option";
                "financing_option" = "";
                options =                 (
                                        {
                        hours = "2.00";
                        jobID = 22000;
                        optionDesc = "Sample Description";
                    },
                                        {
                        hours = "2.00";
                        jobID = 22000;
                        optionDesc = "Sample Description";
                    },
                );

            }
        );
        "system_observations" = "";
    };
    name = tester;
    "sort_order" = 179;
    "system_observations" = "";
}
)
试用代码:-

 NSArray *allJobs = [self getAllJobs];
                allJobs = [allJobs filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"(dept_id == %@)",deptId]];

                NSMutableArray *coumpoArray = [NSMutableArray new];
                for (NSDictionary *job in allJobs) {
                    NSPredicate *predicateDeepFilterJobID = [NSPredicate predicateWithFormat:@"json.option_titles.options.jobID == %@",job[@"id" ]];
                    [coumpoArray addObject:predicateDeepFilterJobID];
                }

                NSPredicate *pr = [NSCompoundPredicate orPredicateWithSubpredicates:coumpoArray];
                filterBydept = [arrayTemplate filteredArrayUsingPredicate:pr];
尝试了另一个谓词:-

 NSArray *allJobs = [self getAllJobs];
                allJobs = [allJobs filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"(dept_id == %@)",deptId]];

                NSMutableArray *coumpoArray = [NSMutableArray new];
                for (NSDictionary *job in allJobs) {
                    NSPredicate *predicateDeepFilterJobID = [NSPredicate predicateWithFormat:@"json.option_titles.ANY.options.ANY.jobID == %@",job[@"id" ]];
                    [coumpoArray addObject:predicateDeepFilterJobID];
                }

                NSPredicate *pr = [NSCompoundPredicate orPredicateWithSubpredicates:coumpoArray];
                filterBydept = [arrayTemplate filteredArrayUsingPredicate:pr];

显示您尝试的代码。添加的示例代码显示您尝试的代码。添加的示例代码