简体   繁体   中英

How to filter data in NSMutableArray that contains NSArray as an object

I want to filter data from NSMutableArray that contains NSArray as an object. Below is code that I have used for set object-

[self setFieldType];
NSMutableArray *kirtanList=[[NSMutableArray alloc] init];
NSString *sql = [NSString stringWithFormat:@"SELECT Id,%@ FROM Kirtan_list  where Title_Eng like '%@%%' or Title_Eng like '%%%@%%' order by Title_Eng", titleField, text,text];
sqlite3_stmt * statement;

if(sqlite3_prepare_v2(db, [sql UTF8String], -1, &statement, nil) == SQLITE_OK)
{

    while(sqlite3_step(statement) == SQLITE_ROW)
    {
        char *field1 = (char *) sqlite3_column_text(statement, 0);
        NSString *field1Str = [[NSString alloc] initWithUTF8String:field1];
        char *field2 = (char *) sqlite3_column_text(statement, 1);
        NSString *field2Str = [[NSString alloc] initWithUTF8String:field2];
        NSArray *data=[NSArray arrayWithObjects:[NSString stringWithFormat:@"%@",field1Str],[NSString stringWithFormat:@"%@",field2Str],nil ];
        [kirtanList addObject:data];
    }
}else{
    NSLog(@"Filtered row error ");
}

help me for filter data.

通过此代码解决

 NSPredicate * predicate = [NSPredicate predicateWithFormat:@"ANY SELF BEGINSWITH[cd] %@",_textField.text];
NSMutableArray *marrObject=[[NSMutableArray alloc] init]; //Declare Array Object

//Loop for find array objects
for (id arrObject in marrObject) {

    if ([arrObject isKindOfClass:[NSArray class]]) {

        NSLog(@"It's Array Object");
    }
} 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM