Is it possible to use an array in a subclass of JSONModel in Swift? Or is this a limitation because it has not yet been updated?
If I do this in Objective-C, in a .h file:
@interface RecommendationModel : JSONModel
@property (strong, nonatomic) NSArray<VenueModel>* recommendations;
@end
It works great.
But if I do this in Swift:
class RecommendationModel: JSONModel {
var recommendations : [VenueModel] = []
}
This did not work. The application starts, but when you try to read JSON, it is interrupted by the message:
Application termination due to an uncaught exception “JSONModelProperty type not allowed”, reason: “App_iOS.RecommendationModel.recommendations property type is not supported by JSONModel. '
The class is JSON and VenueModelidentical for Objective-C and Swift.
Any way to make it work in Swift?
source
share