I am trying to parse JSON using Codable in swift 4. My concern is
public class entStatusAndDescription : NSObject {
var status : Int?
var statusDescription : String?
var records : AnyObject?
}
I want the above entity to be codable but the "records" cant be specific entity, as this is my base entity that I will receive from API. After I parse the status and statusDescription, only then I can specify which entity will records be
e.g I am calling API for customer details and i receive status as 200 i.e success then I will parse records to Customer entity
Any(Object)with Codable. At least you have to write a custom initializer to determine the concrete type(s). By the way: In Swift you don’t need classes inherited fromNSObjectin most cases. And why isstatusoptional? Most likely the API is always sending this key.