Reputation: 991
I have two Data Base which is shown in the attacted picture
I have the NewRelease Object and i want to get it's parent Object which is Contract. Means i want to know that this NewRelease Object belong to which Contract. I am unable to fetch the data can any one guide be what should be a rite predicate for this situation. I am successfully fetching the data for it's inverse case in NewRelease and Signature Table using this predicate Line
NSArray *filterResults = [mutableFetchResults filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"hasNewReleases = %@",aNewRelease]];
where aNewRelease is my NewRelease Object now how can i fetch data from Contracts Table using NewRelease Object.
There is "One to Many" Relation between NewRelease and Contracts such that one single Contract can belong to multiple NewReleases. Npw as i have mention above i have newRelease Object and i want to know that this newRelease belong to which Contract.
Upvotes: 0
Views: 1047
Reputation: 1838
Add relationship between NewRelease and Contract table , then whenever you will fetch data from NewRelease or Contract entity ,you can access the data with its associated relationship. Check the following example : http://www.raywenderlich.com/934/core-data-on-ios-5-tutorial-getting-started
Upvotes: 1
Reputation: 8947
you should add an attribute naming contracId in NewRelease. So that there is always an id of contract for each NewRelease object and hence you can easily fetch data for each new release using the contractID.
chill :)
Upvotes: 1