CoreData Relationships Clarification: How to effectively set an inverse relationship?

I'm a bit confused about why you're calling alloc / init on Story directly. I suspect that if you're doing the same thing elsewhere in your code (which you should publish for us to gawk at) then the "sentence" object passed in to addStoryItemAction: is probably NOT a properly initialized NSManagedObject.

I'm a bit confused about why you're calling alloc / init on Story directly. I suspect that if you're doing the same thing elsewhere in your code (which you should publish for us to gawk at) then the "sentence" object passed in to addStoryItemAction: is probably NOT a properly initialized NSManagedObject. The error you are encountering means that the underlying class has not properly implemented the accessors for that property "belongsTo", so it would seem something went afoul in your initialization code.

You should be using: NSEntityDescription *entityFromModel = aModel entitiesByName valueForKey:@"Sentence"; Sentence *sentence = (Sentence *)NSManagedObject alloc initWithEntity:entityFromModel insertIntoManagedObjectContext:context.

Thanks for the answer. I won't have a chance to try out your answer for a couple days, but I'm looking forward to seeing if the answer will fix up where I'm going wrong. In the meantime, as you've requested I've added extra relevant code - hope that clarifies things a bit.

Cheers again! – glenstorey Oct 21 '10 at 2:36 From looking at the implementation files you're definitely missing calls to the NSManagedObject's designated initializer initWithEntity:insertIntoManagedObjectContext. A suitable remedy (if you still wanted to use those wrappers) would be to change them to take a managed object context argument and call super initWithEntity:anEntityDescription insertIntoManagedObjectContext:passedInContext.

– ImHuntingWabbits Oct 21 '10 at 10:16 Thanks IHW, I used the initWithEntity statement rather than my own initializer and now I'm working fine. Thanks for your answer! – glenstorey Oct 23 '10 at 1:15.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions