KevinHM/FunctionalReactiveProgrammingOniOS

"FunctionalReactivePixels的基础知识"小节中的 configurePhotoModel 的问题

huaf22 opened this issue · 0 comments

+ (void)configurePhotoModel:(FRPPhotoModel *)photomodel withDictionary:(NSDictionary *)dictionary{
    //Basic details fetched with the first, basic request
    photomodel.photoname = dictionary[@"name"];
    photomodel.identifier = dictionary[@"id"];
    photomodel.photographerName = dictionary[@"user"][@"username"];
    photomodel.rating = dictionary[@"rating"];

    photomodel.thumbnailURL = [self urlForImageSize:3 inArray:dictionary[@"images"]];

    //Extended attributes fetched with subsequent request
    if (dictionary[@"comments_count"]){
        photomodel.fullsizedURL = [self urlForImageSize:4 inArray:dictionary[@"images"]];
    }
}

这个方法的功能是通过参数 dictionary 来给 photomodel 对象赋值, 这样的话可以将该方法作为 FRPPhotoModel 对象的一个构造函数, 这样也可以给其他类调用