1

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.

6
  • detect type of class by using [object1 isKindOfClass:[NSArray class]] Commented Jun 24, 2016 at 5:47
  • On what condition do you want to filter the data ? Commented Jun 24, 2016 at 5:54
  • using NSPredicate with formate like NSPredicate * predicate = [NSPredicate predicateWithFormat:@"AnyName BEGINSWITH[cd] %@",_textField.text]; Commented Jun 24, 2016 at 5:58
  • Refer this developer.apple.com/library/mac/documentation/Cocoa/Conceptual/… Commented Jun 24, 2016 at 6:06
  • not useful above link Commented Jun 24, 2016 at 6:43

2 Answers 2

0

Solve this by this code

 NSPredicate * predicate = [NSPredicate predicateWithFormat:@"ANY SELF BEGINSWITH[cd] %@",_textField.text];
Sign up to request clarification or add additional context in comments.

Comments

-2
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");
    }
} 

1 Comment

The question is about to filter NSArray object and i do that.And it's not posssible that i write whole code which is describe in question regarding sqlite.And after finding NSArray object he can do further process.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.