For example, there are two models Realm Information
import Foundation
import RealmSwift
class Music: Object {
dynamic var id = ""
dynamic var title = ""
dynamic var url = ""
}
class DownloadMusic: Object {
dynamic var id = ""
dynamic var title = ""
dynamic var path = ""
}
func test(object: AnyObject) {
}
let realm = try! Realm()
test(realm.objects(Music)[0])
Try using .isKindOfClass(Music) or .isKindOfClass(DownloadMusic) methods
EDIT: as Jonathan pointed the correct way would be
if let musicObject = object as? Music
I tried to draw the analogy with Obj-C first, but then looked that in swift it's done differently