Model collections not found in swift for xcode9&swift4
Tuluobo opened this issue · comments
Tuluobo commented
In Xcode9 and Swift4:
Model:
// interface
@protocol People;
@interface People: JSONModel
@property(nonatomic, readwrite, strong) NSString *name;
@property(nonatomic, readwrite) NSInteger age;
@end
@protocol Car;
@interface Car: JSONModel
@property(nonatomic, readwrite, strong) NSString *name;
@property(nonatomic, readwrite, strong) NSString *color;
@end
@interface City: JSONModel
@property(nonatomic, readwrite) double area;
@property(nonatomic, readwrite, strong) NSMutableArray<People> *peoples;
@property(nonatomic, readwrite, strong) NSMutableArray<Car> *cars;
@end
// implementation
@implementation People
@end
@implementation Car
@end
@implementation City
@end
// Test
NSDictionary *dict = @{
@"area" : @13,
@"peoples" : @[
@{@"name" : @"jony", @"age" : @23},
@{@"name" : @"july", @"age" : @25} ],
@"cars" : @[
@{@"name" : @"M", @"color" : @"red"},
@{@"name" : @"B", @"color" : @"green"} ]
};
NSError *err = nil;
City *city = [[City alloc] initWithDictionary:dict error:&err];
NSLog(@"%@", city);
In Objective-C , it's OK.
George Ymydykov commented
@Tuluobo any solutions? Have the same issue.
George Ymydykov commented
@Tuluobo looks like need to migrate to another library now :(
James Billingham commented
If you can figure out how this needs to be resolved, please open a PR and I’ll be happy to get it included into the project. Unfortunately I don’t use Swift so am not able to help very much with finding a solution.