Note that there are some explanatory texts on larger screens.

plurals
  1. POCore Data Detail View with relationship
    text
    copied!<p>I have set up a <strong>1 to many relationship</strong> on my core data entities. I am trying to show the detailview copy of the associated data. Currently I have the prepareforseague: method working with the original entity(Routines), however I am at a lose as to how to show the linked entity (RoutinesDetails).</p> <p><img src="https://i.stack.imgur.com/f3OhS.png" alt="enter image description here"></p> <p><strong>FBCDRoutineViewController</strong></p> <pre><code> - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; // Fetch the devices from persistent data store NSManagedObjectContext *managedObjectContext = [self managedObjectContext]; NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] initWithEntityName:@"Routines"]; self.routines = [[managedObjectContext executeFetchRequest:fetchRequest error:nil] mutableCopy]; [self.tableView reloadData]; } - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([[segue identifier] isEqualToString:@"UpdateDevice"]) { NSManagedObject *selectedDevice = [self.routines objectAtIndex:[[self.tableView indexPathForSelectedRow] row]]; FBCDRoutineViewController *destViewController = segue.destinationViewController; destViewController.routines = selectedDevice; } </code></pre> <p><strong>FBCDRoutineDetailViewController</strong></p> <pre><code>- (NSManagedObjectContext *)managedObjectContext { NSManagedObjectContext *context = nil; id delegate = [[UIApplication sharedApplication] delegate]; if ([delegate performSelector:@selector(managedObjectContext)]) { context = [delegate managedObjectContext]; } return context; } - (id)initWithStyle:(UITableViewStyle)style { self = [super initWithStyle:style]; if (self) { // Custom initialization } return self; } - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; // Fetch the devices from persistent data store NSManagedObjectContext *managedObjectContext = [self managedObjectContext]; NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] initWithEntityName:@"RoutinesDetails"]; self.routines = [[managedObjectContext executeFetchRequest:fetchRequest error:nil] mutableCopy]; } - (void)viewDidLoad { [[self navigationController] setNavigationBarHidden:NO animated:YES]; [super viewDidLoad]; // Do any additional setup after loading the view. if (self.routines) { [self.testLabel setText:[self.routines valueForKey:@"routinename"]]; } } </code></pre> <p><strong>FBCDRoutineDetailViewController</strong></p> <pre><code>@property (strong) NSManagedObject *routines; </code></pre> <p>This is my first time with core data and I am looking at how to show the Details entity. Am I Close to getting it working? If not can I get directed at to what I should be looking at. </p> <p>Any suggestions?</p>
 

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