You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Define a content model SomeModel in Contentful with a to-one relationship to another model SomeOtherModel. Let's call this relationship in Contentful toOneRelationship
Define the core data model with the to-one relationship, but in the core data model, call the relationship justOne
Define the core data NSManagedObject class as EntryPersistable, with the following field mapping:
classSomeOtherModel:NSManagedObject,EntryPersistable{}classSomeModel:NSManagedObject,EntryPersistable{// this is called "toOneRelationship" in the Contentful model@NSManagedvarjustOne:SomeOtherModel?staticfunc fieldMapping()->[FieldName:String]{["toOneRelationship":"justOne"]}}
During the sync operation, ContentfulPersistence will attempt to set the relationship on this managed object using the toOneRelationship name, rather than the justOne field name, resulting in a crash.
Only workaround seems to be to rename the relationship in the Contentful model definition.
The text was updated successfully, but these errors were encountered:
… and I found that it actually works.
The problem was a stale cache - I had been using the old property name in the managed object model, decided there was a better name, renamed it in Core Data, updated the mapping, etc. Also had deleted the persistent store and created from scratch. However, ContentfulPersistence had a cache on disk containing the old mapping. After I removed the app and reinstalled (which obviously removed the cache) then it started working.
Steps to reproduce:
SomeModel
in Contentful with a to-one relationship to another modelSomeOtherModel
. Let's call this relationship in ContentfultoOneRelationship
justOne
NSManagedObject
class asEntryPersistable
, with the following field mapping:During the sync operation, ContentfulPersistence will attempt to set the relationship on this managed object using the
toOneRelationship
name, rather than thejustOne
field name, resulting in a crash.Only workaround seems to be to rename the relationship in the Contentful model definition.
The text was updated successfully, but these errors were encountered: