Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //
  2. //  SecondLevelTableViewController.m
  3. //  OKCIS
  4. //
  5. //  Created by Brian Hosie on 10/29/10.
  6. //  Copyright 2010 __MyCompanyName__. All rights reserved.
  7. //
  8.  
  9. #import "OccupationsRootViewController.h"
  10. #import "SecondLevelTableViewController.h"
  11. #import "Occupation.h"
  12.  
  13. @implementation SecondLevelTableViewController
  14.  
  15. @synthesize occupationInfo;
  16. @synthesize context;
  17.  
  18. #pragma mark -
  19. #pragma mark Initialization
  20.  
  21. /*
  22. - (id)initWithStyle:(UITableViewStyle)style {
  23.     // Override initWithStyle: if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
  24.     if ((self = [super initWithStyle:style])) {
  25.     }
  26.     return self;
  27. }
  28. */
  29.  
  30.  
  31. #pragma mark -
  32. #pragma mark View lifecycle
  33.  
  34.  
  35. - (void)viewDidLoad {
  36.     [super viewDidLoad];
  37.    
  38.     NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
  39.     NSEntityDescription *entity = [NSEntityDescription
  40.                                    entityForName:@"Occupation" inManagedObjectContext:context];
  41.     [fetchRequest setEntity:entity];
  42.     NSError *error;
  43.     self.occupationInfo = [context executeFetchRequest:fetchRequest error:&error];
  44.     self.title = @"Occupations";
  45.    
  46.     [fetchRequest release];
  47.    
  48. }
  49.  
  50.  
  51. /*
  52. - (void)viewWillAppear:(BOOL)animated {
  53.     [super viewWillAppear:animated];
  54. }
  55. */
  56. /*
  57. - (void)viewDidAppear:(BOOL)animated {
  58.     [super viewDidAppear:animated];
  59. }
  60. */
  61. /*
  62. - (void)viewWillDisappear:(BOOL)animated {
  63.     [super viewWillDisappear:animated];
  64. }
  65. */
  66. /*
  67. - (void)viewDidDisappear:(BOOL)animated {
  68.     [super viewDidDisappear:animated];
  69. }
  70. */
  71. /*
  72. // Override to allow orientations other than the default portrait orientation.
  73. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
  74.     // Return YES for supported orientations
  75.     return (interfaceOrientation == UIInterfaceOrientationPortrait);
  76. }
  77. */
  78.  
  79.  
  80. #pragma mark -
  81. #pragma mark Table view data source
  82.  
  83. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  84.     // Return the number of sections.
  85.     return 1;
  86. }
  87.  
  88.  
  89. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  90.     // Return the number of rows in the section.
  91.     return [occupationInfo count];
  92. }
  93.  
  94.  
  95. // Customize the appearance of table view cells.
  96. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  97.    
  98.     static NSString *CellIdentifier = @"Cell";
  99.    
  100.     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  101.     if (cell == nil) {
  102.         cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
  103.     }
  104.    
  105.     // Configure the cell...
  106.    
  107.     return cell;
  108. }
  109.  
  110.  
  111. /*
  112. // Override to support conditional editing of the table view.
  113. - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
  114.     // Return NO if you do not want the specified item to be editable.
  115.     return YES;
  116. }
  117. */
  118.  
  119.  
  120. /*
  121. // Override to support editing the table view.
  122. - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
  123.    
  124.     if (editingStyle == UITableViewCellEditingStyleDelete) {
  125.         // Delete the row from the data source
  126.         [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
  127.     }  
  128.     else if (editingStyle == UITableViewCellEditingStyleInsert) {
  129.         // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
  130.     }  
  131. }
  132. */
  133.  
  134.  
  135. /*
  136. // Override to support rearranging the table view.
  137. - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
  138. }
  139. */
  140.  
  141.  
  142. /*
  143. // Override to support conditional rearranging of the table view.
  144. - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
  145.     // Return NO if you do not want the item to be re-orderable.
  146.     return YES;
  147. }
  148. */
  149.  
  150.  
  151. #pragma mark -
  152. #pragma mark Table view delegate
  153.  
  154. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  155.     // Navigation logic may go here. Create and push another view controller.
  156.     /*
  157.      <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
  158.      // ...
  159.      // Pass the selected object to the new view controller.
  160.      [self.navigationController pushViewController:detailViewController animated:YES];
  161.      [detailViewController release];
  162.      */
  163. }
  164.  
  165.  
  166. #pragma mark -
  167. #pragma mark Memory management
  168.  
  169. - (void)didReceiveMemoryWarning {
  170.     // Releases the view if it doesn't have a superview.
  171.     [super didReceiveMemoryWarning];
  172.    
  173.     // Relinquish ownership any cached data, images, etc that aren't in use.
  174. }
  175.  
  176. - (void)viewDidUnload {
  177.     // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
  178.     // For example: self.myOutlet = nil;
  179. }
  180.  
  181.  
  182. - (void)dealloc {
  183.     [super dealloc];
  184. }
  185.  
  186.  
  187. @end
  188.  
  189. /************* CONSOLE ERROR *************************/
  190.  
  191. *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '+entityForName: could not locate an NSManagedObjectModel for entity name 'Occupation''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement