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

Convert NsNumber, NSDate to String in iOS Swift

Global LocationManager Singleton class iOS Swift