Can anyone explain me what this code does after getting NSArray….
- (UIViewController *)sampleForIndexPath:(NSIndexPath *)indexPath {
NSArray *samples = [samples_ objectAtIndex:indexPath.section];
Class clazz = [samples objectAtIndex:indexPath.row];
UIViewController *instance = [[clazz alloc] initWithNibName:nil bundle:nil];
return [instance autorelease];
}
I am getting NSArray of Section… then how can we assign the values of the row to a Class??
Here the array samples contains the objects of type Class. You can create an instance of class directly using a class name or by using a Class object/variable. For example,
Your code uses the second way to allocate the view controller object from the class object returned by [samples objectAtIndex:indexPath.row].