Though the same question has been asked many a times and the answers were to --> Typecast the array to the required array of class type.
Though i did it typecasting I am still facing the same error with the crash.
Here is my code:
let data = Model.dictArrayFromModel(dict.objectForKey("category_plans")! as! [Model])
public class func dictArrayFromModel(planCategories: [Model]) -> NSArray {
let jsonArray: NSMutableArray = NSMutableArray()
for categoryPlans in planCategories {
jsonArray.addObject(categoryPlans.dictionaryRepresentation())
}
for plans in planCategories {
jsonArray.addObject(plans.dictionaryRepresentation())
}
return jsonArray
}
When i try to use for-in Loop it crashes with the error fatal error: NSArray element failed to match the Swift Array Element type
Inspite of doing the type casting the code is crashing. I do not know what i am missing. Any immediate help will be greatly appreciated.
P.S :
The major use case here is I am trying to pass this data
the Array or Model to class Model for further processing.