ibireme / YYModel

High performance model framework for iOS/OSX.
MIT License
4.34k stars 917 forks source link

关于这个方法的小建议:+ (NSArray *)yy_modelArrayWithClass:(Class)cls json:(id)json; #85

Open wyhazq opened 8 years ago

wyhazq commented 8 years ago

如果不影响效率,在NSObject (YYModel)增加这样一个方法可好?

BenjaminX commented 8 years ago
+ (id) modelWithJSON:(id) json {
    id objs = nil;

    if ([json isKindOfClass:[NSArray class]]) {
        objs = [NSArray yy_modelArrayWithClass:[self class] json:json];
    } else if([json isKindOfClass:[NSDictionary class]]) {
        objs = [self yy_modelWithJSON:json];
    } else if([json isKindOfClass:[NSString class]]) {
        objs = [self yy_modelWithJSON:json];
    } else if([json isKindOfClass:[NSData class]]) {
        objs = [self yy_modelWithJSON:json];
    }
    return objs;
}