Reputation: 13262
Song
is a subclass of RLMObject
(typealias Object
) and is used throughout my app, including in searchViewController(_:cellForObject:atIndexPath:)
let song = object as! Song
But in my prepare(for segue:)
method (below), when I try to perform the same downcast, the compiler says "Cast from 'RLMObject' to unrelated type 'Song' always fails."
if let row = tableView.indexPathForSelectedRow?.row {
YpbApp.currentRequest?.songObject = results!.object(at: UInt(row)) as? Song
}
This doesn't makes sense, what's wrong here?
Upvotes: 0
Views: 270
Reputation: 8138
RLMObject
is not a typealias for Object
; they are different classes entirely that have different interfaces. It sounds like you are trying to mix the Swift and Objective-C APIs, which is not supported.
Upvotes: 3