jsonmodel / jsonmodel

Magical Data Modeling Framework for JSON - allows rapid creation of smart data models. You can use it in your iOS, macOS, watchOS and tvOS apps.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Swift class override classForCollectionProperty twice build error

ladmini opened this issue · comments

Hi guys, Thank you very much to bring me a so powerful library. It works well in swift.
But I found a problem. Could you please help me?
I have a Response model like this

class ResponseModel: JSONModel {
    var status = ""
    var message:[MessageModel] = []
    override static func classForCollectionProperty(propertyName:String) -> AnyClass?{
        switch propertyName {
        case "message":
            return MessageModel.self
        default:
            return nil
        }
    }
}

class MessageModel:JSONModel{
}

I also have a Submodel of ResponseModel like this

class LocationModels: ResponseModel {
    var model:[LocationModel] = []
    override static func classForCollectionProperty(propertyName:String) -> AnyClass?{
        switch propertyName {
        case "model":
            return LocationModel.self
        default:
            return super.classForCollectionProperty(propertyName: propertyName)
        }
    }
}

class LocationModel:BaseModel{
}

But this code compile failed. Because In swift the classForCollectionProperty method can only be override once.

So Could you please help to tell me how can I achieve this demand?