Type 'mymodel' does not conform to protocol 'Decodable' iOS swift

Problem: 

Type 'mymodel' does not conform to protocol 'Decodable'.Error came for my code.


struct mymodel:Decodable {

    var startsOn:Int64 = 0

    var endsOn:NSNumber = 0

    var objID:String = ""

}


Solution:


Because it has nsnumber object inside.It will not be decodable.You have to change like below.It will works fine.



struct mymodel:Decodable {

    var startsOn:Int64 = 0

    var endsOn: Int64 = 0

    var objID:String = ""

}


Comments

Popular posts from this blog

Invalid bundle error while upload the app to the app Store

store cgpoint in userdefaults iOS swift