• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
newbie problems with master-detail relationship
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

newbie problems with master-detail relationship


  • Subject: newbie problems with master-detail relationship
  • From: shaun bear <email@hidden>
  • Date: Sun, 29 Oct 2006 22:58:59 +0100

I have created a test program with a master detail relationship. It contains 2 Entities:
"Master" and "Detail". I have generated custom classes that sub- class Managed Object
Class automatically for these entities, with accessors with Xcode.
I have then dragged the entities into interface builder,creating a tableview bound to their
respective object arrays. I have bound "Detail Array Controller"Content set to "Master Array Controller".
I have set the Object class name for each Array controller to their respective classes.
This works fine if I want to add new rows using the interface.
Next I created an method: add in MyDocument, because I want to be able to add new "Master" and "Detail"
records, programatically at runtime. When the method: add (below) is invoked, the the new row shows up for the Master
table but not the Detail row. If invoke the method a second time, I get the following error message:
[<NSCFString 0x2d04c> valueForUndefinedKey:]: this class is not key value coding-compliant for the key child.
I have the following accessors for the key child in the Detail.h :


// Declaration

- (NSString *)child;
- (void)setChild:(NSString *)value;

Am I adding instantiating the  detail object correctly?
Is somthing I should be doing in bindings that I am missing?
Can you see anything wrong with method: add?

Thanks in advance for your help?




- (IBAction)add:(id)sender {


NSManagedObjectContext *managedObjectContext = [self managedObjectContext];
[[managedObjectContext undoManager] disableUndoRegistration];



master =[NSEntityDescription insertNewObjectForEntityForName:@"Master" inManagedObjectContext:managedObjectContext]; [master setParent:@"test"];

	detail =  [NSEntityDescription
	insertNewObjectForEntityForName:@"Detail"
	inManagedObjectContext:managedObjectContext];

	[detail setChild:@"test"];

   [master  addDetailObject:  @"detail"];

	[managedObjectContext processPendingChanges];
	[[managedObjectContext undoManager] enableUndoRegistration];

}


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: newbie problems with master-detail relationship
      • From: Scott Stevenson <email@hidden>
  • Prev by Date: Owner/Group changes depending on which volume you're booted from?
  • Next by Date: Re: Owner/Group changes depending on which volume you're booted from?
  • Previous by thread: Re: Owner/Group changes depending on which volume you're booted from?
  • Next by thread: Re: newbie problems with master-detail relationship
  • Index(es):
    • Date
    • Thread