Visitar URL original
Swift class override classForCollectionProperty twice build error · Issue #590 · jsonmodel/jsonmodel · GitHub
Skip to content

Swift class override classForCollectionProperty twice build error #590

Open

Description

@ladmini

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions