I have my Swift 3
project that I wanted to convert to Swift 4
.
When compiling after conversation I get a few errors (all the same) regarding Inheritance from non-protocol
.
This is the class that is triggering the error:
import Foundation
import ObjectMapper
//MARK: - Equatable
func ==(lhs: ProcedureSearchModel, rhs: ProcedureSearchModel) -> Bool {
return lhs.hashValue == rhs.hashValue
}
class ProcedureSearchModel : AnyObject, Mappable, Hashable {
var procedureUid : String = ""
var cpt : String = ""
var description : String = ""
required init?(map: Map) {
}
//MARK: - Hashable
var hashValue : Int {
get {
return procedureUid.hashValue
}
}
init (procedureUid : String, cpt: String, description : String) {
self.procedureUid = procedureUid;
self.cpt = cpt;
self.description = description
}
// Mappable
func mapping(map: Map) {
procedureUid <- map["ProcedureUid"]
cpt <- map["CPT"]
description <- map["Description"]
}
}
Any clue on how to resolve this issue?
Thanks
答案 0 :(得分:1)
您的类定义不能包含AnyObject。 AnyObject不是类或协议。
您要么需要从类定义中删除AnyObject,要么将其替换为NSObject(如果您希望它是与Objective-C兼容的类。
class ProcedureSearchModel : Mappable, Hashable {
}
或者:
class ProcedureSearchModel : NSObject, Mappable, Hashable {
}