nofelmahmood / Seam

Seamless CloudKit Sync with CoreData
https://medium.com/@Nofel/reason-why-cloudkit-cannot-be-ignored-9c7806d76230
MIT License
669 stars 64 forks source link

Crash because of NSMutableOrderedSet #31

Open dehlen opened 8 years ago

dehlen commented 8 years ago

Hello,

When using this library I get the following error message: Could not cast value of type '_NSFaultingMutableOrderedSet' (0x19fe9c2e8) to 'NSSet' (0x19fe879e8). It occurs in SMStore.swift - setRelationshipValuesForBackingObject: because of this line:

let relationshipValue: Set<NSObject> = sourceObject.valueForKey(relationship.name) as! Set<NSObject>

I can't find my mistake since I already got the inverse relations set up as you are describing in the README. I hope you can give me a hint why this does not work.

Here is my xcdatamodeld setup : bildschirmfoto 2015-12-28 um 18 32 51 bildschirmfoto 2015-12-28 um 18 32 29 bildschirmfoto 2015-12-28 um 18 32 40 bildschirmfoto 2015-12-28 um 18 32 15

chbeer commented 8 years ago

The error indicates that the OrderedSet can not be casted to a regular Set.

Depending on how relationshipValue is used you either can use an iterative protocol that both Set and OrderedSet implement. Or you need to have different ways to use relationshipValue

chbeer commented 8 years ago

By "you" I mean Seams SMStore.swift that you could fix.