【问题标题】:NSpredicate to filter the Array of Elements that has substringsNSpredicate 过滤具有子字符串的元素数组
【发布时间】:2012-12-18 10:50:42
【问题描述】:

我已经编写了 NSPredicate 来过滤元素。

-(void)filterResult:(NSMutableArray*)array
{
    search=TRUE;
    filteredCategoryList=[[NSArray alloc]init];


    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"roles beginsWith %@ ||     UserResponseDetails IN %@ ",array,array];
    filteredCategoryList = [MembersList filteredArrayUsingPredicate:predicate]; 
    [filteredCategoryList retain];
}

问题是我在 Roles 中得到一个字符串,如“sample;Example”,而其他字符串是单个字符串。如何编写谓词条件以获取 Sample、Example、sample 和 Example 的元素。 .

【问题讨论】:

标签: iphone cocoa-touch nsarray nspredicate


【解决方案1】:

我得到了一个解决方案,我必须在谓词中使用“包含”关键字而不是“开始于”。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-11-11
    • 2019-04-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-14
    • 1970-01-01
    相关资源
    最近更新 更多