Swift3 Swift 4迁移-从非协议、非类AnyObject继承
我有我的Swift3 Swift 4迁移-从非协议、非类AnyObject继承,swift3,swift4,Swift3,Swift4,我有我的swift3项目,我想转换成swift4 在对话之后进行编译时,我遇到了一些关于从非协议继承的错误(都是一样的) 这是触发错误的类: import Foundation import ObjectMapper //MARK: - Equatable func ==(lhs: ProcedureSearchModel, rhs: ProcedureSearchModel) -> Bool { return lhs.hashValue == rhs.hashValue
swift3
项目,我想转换成swift4
在对话之后进行编译时,我遇到了一些关于从非协议继承的错误(都是一样的)
这是触发错误的类:
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"]
}
}
<代码>导入基础
导入对象映射器
//马克:相等
func==(lhs:ProcedureSearchModel,rhs:ProcedureSearchModel)->Bool{
返回lhs.hashValue==rhs.hashValue
}
类ProcedureResearchModel:任意对象、可映射、可哈希{
var procedureUid:String=“”
var cpt:String=“”
变量说明:String=“”
必需的初始化?(映射:映射){
}
//标记:-可散列
var hashValue:Int{
得到{
返回过程ID.hashValue
}
}
init(procedureId:String,cpt:String,description:String){
self.procedureId=程序ID;
self.cpt=cpt;
self.description=描述
}
//可映射
func映射(映射:映射){
过程ID您的类定义不能包含任何对象。任何对象不是类或协议
您需要从类定义中删除任何对象,或者将其替换为NSObject(如果您希望它是与Objective-C兼容的类)
class ProcedureSearchModel : Mappable, Hashable {
}
或:
class ProcedureSearchModel : NSObject, Mappable, Hashable {
}