Fast Enumeration of a NSFetchedResult

66 views Asked by At

So I have a NSFetchedResultsController. I have it working fine for normally displaying the data. I have a situation where I need to be able to enumarate through them. So I fetch the results as seen here:

if (![[self fetchedResultsController] performFetch:&error]) {

        exit(-1);  // Fail
    }

I need to do some work with the data before I display it so I am assigning it to an array like this:

 arrVacationResults = [fetchedResultsController fetchedObjects];

Works perfectly so far. I now have an array of fetchedObjects. I tried to use fast enumeration but how do I reference whats in each array. I assumed it was a dictionary of sort so I tried to do something like

for (NSDictionary *myVacation in arrVacationResults)
{

}

That fails because in arrVacationResults they are not NSDictionaries, so what are they?

1

There are 1 answers

0
RegularExpression On BEST ANSWER

It is an array of NSManagedObjects:

for (NSManagedObject *myVacation in arraVacationResults)
{
 //
 //  if you need to cast it as your entity
 //
    VacationResultEntity *entity = (VacationResultEntity *) myVacation;   
}