Hey guys. My first time playing with Core data. I've hit a little snag and after reading the docs and tutorials I could find. I'm still stumped.
The problem is that I need to create an instance of an entity whenever an instance of another entity is created.
I have a 'Language' entity which has a relationship to a 'Generator' Entity. The relationship is one to one. The generator uses a custom class that inherits from NSManagedObject (it needs to do some other stuff besides manage data)
In the nib file I have an NSArrayController for the Language entities and an NSController object for the Generator. The NSController gets it's content from a selection binding to the Language NSArrayController.
Now when I create a new language in the NSArrayController I need it to create a new instance of the generator to accompany it.
So i created a custom class for the Language Entity and implemented init like this
But that doesn't seem to do the trick. When i add a new Language I don't seem to get a new Generator. (i've got other interface elements that access attributes of the generator and i can't add items to them, even though they are connected properly)
The problem is that I need to create an instance of an entity whenever an instance of another entity is created.
I have a 'Language' entity which has a relationship to a 'Generator' Entity. The relationship is one to one. The generator uses a custom class that inherits from NSManagedObject (it needs to do some other stuff besides manage data)
In the nib file I have an NSArrayController for the Language entities and an NSController object for the Generator. The NSController gets it's content from a selection binding to the Language NSArrayController.
Now when I create a new language in the NSArrayController I need it to create a new instance of the generator to accompany it.
So i created a custom class for the Language Entity and implemented init like this
Code:
-(id)init
{
if(self = [super init])
{
newGenerator = [[Generator alloc] init];
[self setobject:newGenerator forKey:@"generator"];
}
}
But that doesn't seem to do the trick. When i add a new Language I don't seem to get a new Generator. (i've got other interface elements that access attributes of the generator and i can't add items to them, even though they are connected properly)