i've looked over this for hours. I am using MagicalRecord. Everything is fine in the application , but in the unit tests i get a swift_dynamicCastClassUnconditional
error when i run the following
func testExampleQCPerson() {
let person = QCPerson.MR_createEntity() as QCPerson //error happens here
person.displayOrder = NSNumber(integer: 0)
let personB = QCPerson.MR_createEntity() as QCPerson
personB.displayOrder = NSNumber(integer: 0)
personB.updateOrderForPrevious()
XCTAssert(person.displayOrder.integerValue == 1, "should have incremented")
}
as the past posts suggest, i need to make my models objective C friendly with @objc(ModelName)
...so i have already done that:
import Foundation
import CoreData
@objc(QCPerson)
class QCPerson: NSManagedObject {
@NSManaged var person_id: NSNumber
@NSManaged var displayOrder: NSNumber
@NSManaged var contactRefrence: String
@NSManaged var name: String
@NSManaged var actionType: String
}
while this makes the rest of the application functional, I'd really prefer to be able to test things as well. i will add, i can do this in the unit test
let xx: AnyObject = QCPerson.MR_createEntity() as AnyObject
XCTAssertNotNil(xx, "should exists")
but that doesn't help me with my class specific needs