I have an array of NSManagedObjects. of which here is a truncated println:
[<NSManagedObject: 0x7f9cbc18cf30> (entity: PTKRMessage; id: 0xd00000000004001a <x-coredata://7EEF4956-FA8F-4DE9-B94C-CF612B40AA77/PTKRMessage/p1> ; data: {...}), <NSManagedObject: 0x7f9cbc18d790> (entity: PTKRMessage; id: 0xd00000000008001a <x-coredata://7EEF4956-FA8F-4DE9-B94C-CF612B40AA77/PTKRMessage/p2> ; data: {...})]
When I try to assign one element to a variable as the NSManagedObject Subclass (PTKRMessage)
let message = self.tableData[indexPath.row] as! PTKRMessage
I got the following error:
Could not cast value of type 'NSManagedObject_PTKRMessage_' (0x7f9cbc320d10) to 'tradersofdom.PTKRMessage' (0x102dda910).
PTKRMessage is defined in PTKRMessage.swift as:
class PTKRMessage: NSManagedObject {
@NSManaged var content: String
...
}
it could be related to cast NSManagedObject to class -> Swift dynamic cast failed but the situation and error message is different.