Reputation: 11
In my data model, I have the below entities:
Album:
- name (required attribute)
- year
- tracks
...
Track:
- name (required attribute)
- Album
...
I have a server data response that includes relationship details by providing just the identifiers of the related objects.
/Albums/1 returns:
{
id:2,
name:"The White Album",
year:1968,
...
tracks: ({id:12}, {id:13}, {id:14})
}
As it stands, AFIncrementalStore can't save the context because the track entity objects are failing validation. Is there any way to address this besides making the relationship optional in the data model?
Upvotes: 0
Views: 120
Reputation: 311
I think if we think to your own model as follows:
from this information we need a relationship between two Entities (one-To_many) ..
you can fetch request with tracks and in method - (NSDictionary *)attributesForRepresentation:(NSDictionary *)representation ofEntity:(NSEntityDescription *)entity fromResponse:(NSHTTPURLResponse *)response
you can check for entity name and mapping data to your model ..
as I know if your model name is like response key from server, AFIncremantalStore will do mapping automatically based on keys on your model and response from server ..
thats all I understand from your question and I hope the answer is satisfy to your question ..
Upvotes: 0