I am currently retrieving objects from Parse.com and saving them to CoreData.
I am then next using NSFetchedResultsController to retrieve objects from CoreData. These objects will then be used to create a table view. Everything i retrieve from CoreData is stored in an NSArray using the following code:
NSArray *fetchedObjects = _fetchedResultsController.fetchedObjects;
Using the fetched objects array i am wanting to load a specific nib file depending on the type of each object. So using the following for loop within cellForRowAtIndexPath i am trying to achieve this:
for (NSManagedObject *o in fetchedObjects)
{
if ([[o valueForKey:@"type"] isEqual: @"Type1"])
{
Type1CustomCell *cell = (Type1CustomCell *)[tableView dequeueReusableCellWithIdentifier:@"type1CustomCell"];
return cell;
}
else if ([[o valueForKey:@"type"] isEqual: @"Type2"])
{
Type2CustomCell *cell = (Type2CustomCell *)[tableView dequeueReusableCellWithIdentifier:@"type2CustomCell"];
return cell;
}
}
The previous code is just an example using 2 types, but within the app there may be more.
The return statement cause the loop to end, which means the loop never gets past the first object. Could someone please give me a point in the right direction of how to load multiple nib files depending on the type of the object I have retrieved?
Thanks