0
votes

I am using JSONModel for creation of complex data models. I have recently migrated to swift and face difficulties during parsing an array of custom data models.

class ABCDomain: JSONModel
{
var sampleBool : Bool!
var sampleArray : Array <XYZDomain>!
}

After parsing, when i access the sampleArray i get the message as "fatal error: NSArray element failed to match the Swift Array Element type".

In Objective C, we would be creating a protocol as well for the XYZDomain, while in Swift a compiler error stating redeclaration is thrown. @property (strong, nonatomic) NSArray* sampleArray;

Primitive data type like Bool as well always appears as nil in the datamodel Please let me know if there is any workaround for this.

1
JSONModel is not fully appropriate to Swift. You should consider it using in Objective C or find another library.ridvankucuk
This is a duplicate. For an answer, see: stackoverflow.com/a/34742709/743957James Billingham

1 Answers

0
votes

I have found this as a good alternative. https://github.com/Hearst-DD/ObjectMapper

I have been using this for a while and don't have a problem with it.