CoreData Fetch Request list on search button on iphne
<p>I have this class method</p>

<pre><code>+(NSMutableArray *) searchObjectsInContext: (NSString*) entityName : (NSPredicate *) predicate : (NSString*) sortKey : (BOOL) sortAscending : (NSManagedObjectContext *) managedObjectContext
{

    NSFetchRequest *request = [[NSFetchRequest alloc] init];
    NSEntityDescription *entity = [NSEntityDescription entityForName:entityName inManagedObjectContext:managedObjectContext];
    [request setEntity:entity]; 

    // If a predicate was passed, pass it to the query
    if(predicate != nil)
    {
        [request setPredicate:predicate];
    }

    // If a sort key was passed, use it for sorting.
    if(sortKey != nil)
    {
        NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:sortKey ascending:sortAscending];
        NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil];
        [request setSortDescriptors:sortDescriptors];
        [sortDescriptors release];
        [sortDescriptor release];
    }

    NSError *error;

    NSMutableArray *mutableFetchResults = [[[managedObjectContext executeFetchRequest:request error:&amp;error] mutableCopy] autorelease];

    [request release];

    return mutableFetchResults;
}
</code></pre>

<p>and in my tableview class i want to search people with name A (my entity name is Parent having attribute name Name having value A,B,C,D  which i am getting from XML)</p>

<p>now how to <strong>search and display only name with only A</strong> in table view</p>

<p>i tried like this when search button is pressed</p>

<pre><code>  entitySearchPredicate=[NSPredicate predicateWithFormat:@"Name==%@", self.searchBar.text]; 

        NSLog(@"fect array %@",entitySearchPredicate);


      //  NSLog(@"entityDescription  %@",entityDescription);


        NSLog(@"array_----------- %@",array);





     NSMutableArray* mutableFetchResultss = [CoreDataHelper searchObjectsInContext:self.entityName :entitySearchPredicate:@"Name":YES :managedObjectContext];
</code></pre>

<p>// this also not working</p>

<pre><code> NSMutableArray* mutableFetchResultss = [CoreDataHelper searchObjectsInContext:self.entityName :entitySearchPredicate:@"Name=='A'":YES :managedObjectContext];




            //NSLog(@"mutableFetchResults value  =%@",mutableFetchResults);

            self.entityArray = mutableFetchResultss;


            NSLog(@"self.entityArray    array_----------- %@",self.entityArray);
</code></pre>
