Preetygeek Preetygeek - 1 year ago 225
iOS Question

Swift3 CoreData crash on iOS9 device

I have CoreData app that is perfectly working on iOS10, written in Swift3, supporting iOS 8.4 and above.

When I try to run it on iOS 9.3.5 I'm getting error:

2016-10-07 17:47:20.596 FormApp[710:179733] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSSet intersectsSet:]: set argument is not an NSSet'

crashing on line:


I have added @objc() to managed object classes. Then I'm getting new error:

CoreData: warning: Unable to load class named 'FormApp.Form' for entity 'Form'. Class not found, using default NSManagedObject instead.

It is happening on line:

let form = NSEntityDescription.insertNewObject(forEntityName: "Form", into: managedObjectContext) as! Form

My config:

Settings of enity



Properties extension

All classes were generated by Xcode. I have tried deleting Module and all configurations. Anyone have idea how to make it work?

Answer Source

For some reason NSSet is expected, but your NSManagedObject code has NSOrderedSet, which is a subclass of NSObject. Try to remove "Arrangment: Ordered" checkmark in your core data model and refactor those relationships to NSSet. Not sure why this happens in iOS 10 but not in iOS 9 though.

P.S. Perhaps you should reconsider your Core Data model? It looks like your Open/Closed questions are going to change their status. If so, I would recommend to make one Question entity with closed bool or status int.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download