Open khushbuInexture opened 3 years ago
As you can see in the debug log it found an NSDictionary where it expected an Array. If you have an array of objects, then EVReflection should handle a single object, that was not an array in the json, as an array. How did you specify the array in the target object?
we have one object which have array of object...as you can see in screen shot I'm simply using EVReflection pod to convert json to our class object...CountryRateDataModel has array of object.
class CountryRateModel: EVObject { var status = "" var success = Bool() var message = "" var data = CountryRateDataModel() var meta = "" } class CountryRateDataModel: EVObject { var rates = [CountryRatesDetailModel]() }
I don't know why it found NSDictornary...perhaps when array is empty then it is not being handled properly by EVReflection class.Also this crash is not happening everytime..but it is reported sometimes in my live application and affecting the performance.
I don't seen an array definition in you class. Most fields are strings. 2 are sub objects. The bool should be defined an other way. see the readme about booleans. There are various ways to define an array, please show me your class definition that includes the array.
Array of object here is being converted to URL..please refer the screen shot i have attached..here we have CountryRatesDetailModel as array of object which is being stored in rates variable.
That looks OK. If you also have a Json that is causing the error, then I could create a unit test to see what's going on and reproduce the issue and maybe fix it.
Besides that, are you sure the Bool() value works?
Yes Bool() does work...please find json response.
{
"status" : "200",
"success" : true,
"message" : "Fetched all countries rate calculation.",
"data" : {
"rates" : [
{
"country" : "Liechtenstein"
},
{
"country" : "Spain"
},
{
"country" : "Cyprus"
},
{
"country" : "Ghana"
},
{
"country" : "Benin"
},
{
"country" : "Netherlands The"
},
{
"country" : "Ireland"
},
{
"country" : "Lithuania"
},
{
"country" : "Latvia"
},
{
"country" : "Malta"
},
{
"country" : "Kosovo"
},
{
"country" : "Croatia (Hrvatska)"
},
{
"country" : "Bulgaria"
},
{
"country" : "Greece"
},
{
"country" : "Slovenia"
},
{
"country" : "Norway"
},
{
"country" : "Luxembourg"
},
{
"country" : "Germany"
},
{
"country" : "Belgium"
},
{
"country" : "Estonia"
},
{
"country" : "Ukraine"
},
{
"country" : "Senegal"
},
{
"country" : "Italy"
},
{
"country" : "Austria"
},
{
"country" : "Romania"
},
{
"country" : "Finland"
},
{
"country" : "Slovakia"
},
{
"country" : "Iceland"
},
{
"country" : "Sweden"
},
{
"country" : "Nigeria"
},
{
"country" : "France"
},
{
"country" : "Denmark"
},
{
"country" : "Portugal"
},
{
"country" : "Hungary"
}
]
},
"meta" : ""
}
Hello,
Is there any update? Are you able to reproduce the crash based on this JSON?
Let me know if you have made any updates so I can update the pods?
Hello,
I'm getting this crash sometimes. I am not able to reproduce this everytime.
if theValue is Array {
return (theValue as AnyObject, valueType, false)
}
Precondition failed: NSArray element failed to match the Swift Array Element type Expected CountryRatesDetailModel but found NSDictionaryI: file /BuildRoot/Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-1100.2.280/swift/stdlib/public/core/ArrayBuffer.swift, line 354 2021-01-04 11:33:13.527870+0530[8041:61326] Precondition failed: NSArray element failed to match the Swift Array Element type Expected CountryRatesDetailModel but found NSDictionaryI: file /BuildRoot/Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-1100.2.280/swift/stdlib/public/core/ArrayBuffer.swift, line 354 2021-01-04 11:35:39.520740+0530[8041:62506] XPC connection interrupted