Note that there are some explanatory texts on larger screens.

plurals
  1. PODrill-down application / Core Data+UITable View+Custom Cell
    primarykey
    data
    text
    <p>i am currently working on a test project which has a tab bar, a drill down table list of Districts --> Schools --> school details.</p> <p>Data store is using core data/.mysqlite</p> <p>**Districts' view is a plain table list which list out districts<br> ***Schools' view is a table view with custom cell which display name,address and picture of schools in the selected district<br> ***Detail view is a sectioned table with more details of the selected school.</p> <p>I have managed to get the district table view setup and display correctly but I am stuck on pushing the 2nd view which is the School view. How could I pass data to the 2nd view or switch the Fetch Result entity? I have tried with different method but it is having error, probably it's because I am using the wrong method or missing something at didSelectRow</p> <p>Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '+entityForName: could not locate an NSManagedObjectModel for entity name 'School'</p> <p>I couldn't find out what the problem is. Would be great if anyone could give me some hints on that.</p> <blockquote> <blockquote> <p>DistrictListTableViewController -- FRO, MOC fetching "District"<br> NSEntityDescription *entity = [NSEntityDescription entityForName:@"District" inManagedObjectContext:managedObjectContext]; [fetchRequest setEntity:entity];</p> </blockquote> </blockquote> <p>@class District;</p> <p>@interface DistrictListTableViewController : UITableViewController { @private NSFetchedResultsController *fetchedResultsController; NSManagedObjectContext *managedObjectContext; }</p> <p>@property (nonatomic, retain) NSFetchedResultsController *fetchedResultsController;<br> @property (nonatomic, retain) NSManagedObjectContext *managedObjectContext;</p> <blockquote> <blockquote> <p>SchoolListTableViewController -- FRO, MOC fetching "School"<br> NSEntityDescription *entity = [NSEntityDescription entityForName:@"School" inManagedObjectContext:managedObjectContext]; [fetchRequest setEntity:entity];</p> </blockquote> </blockquote> <p>@class School;</p> <p>@interface DistrictListTableViewController : UITableViewController { @private NSFetchedResultsController *fetchedResultsController; NSManagedObjectContext *managedObjectContext; }</p> <p>@property (nonatomic, retain) NSFetchedResultsController *fetchedResultsController;<br> @property (nonatomic, retain) NSManagedObjectContext *managedObjectContext;</p> <blockquote> <blockquote> <p>Both DistrictListTableViewController &amp; SchoolListTableViewController .m files are pretty much the same except School View loads the SchoolTableViewCell file, I don't know if this is the right method.</p> </blockquote> <p>-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {<br> SchoolListTableViewController *schoolViewController = [[SchoolListTableViewController alloc] initWithStyle:UITableViewStylePlain];<br> [self.navigationController pushViewController:mallViewController animated:YES];<br> [schoolViewController release];<br> }</p> </blockquote> <p>I am pretty new to this, so please tell me where did I do wrong and what is the right method of passing the entity and data to the 2nd view and how.</p> <p>Thank you very much.</p> <p>thanks and this is my fetchedcontroller part</p> <blockquote> <p>> - (NSFetchedResultsController *)fetchedResultsController {</p> </blockquote> <pre><code>if (fetchedResultsController != nil) { return fetchedResultsController; } NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"District" inManagedObjectContext:managedObjectContext]; [fetchRequest setEntity:entity]; NSSortDescriptor *locateDescriptor = [[NSSortDescriptor alloc] initWithKey:@"territory" ascending:YES]; NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:locateDescriptor, nil]; [fetchRequest setSortDescriptors:sortDescriptors]; NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:managedObjectContext sectionNameKeyPath:@"territory" cacheName:@"Root"]; self.fetchedResultsController = aFetchedResultsController; fetchedResultsController.delegate = self; [aFetchedResultsController release]; [fetchRequest release]; [locateDescriptor release]; [sortDescriptors release]; return fetchedResultsController; </code></pre> <p>} </p> <p>so, in the School controller, i would just switch "District" with "School" and sort description with the name of the school.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload