You need to write something like this
-(NSMutableArray *)getRandomArrayFromDB { NSMutableArray *fetchResults; NSString * entityName=@ "questionsdata"; NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:entityName inManagedObjectContext:globalManagedObjectContext]; [fetchRequest setEntity:entity]; fetchResults = [NSMutableArray arrayWithArray:[globalManagedObjectContext executeFetchRequest:fetchRequest error:nil]]; [fetchRequest release]; NSString * cat=@ "Logic"; [fetchResults filterUsingPredicate:[NSPredicate predicateWithFormat:@"questiontype == %@",cat]];
call this method and it gives what you want.
source share