brunow / BaseKit

BaseKit is a set of IOS class to make your life easier.
https://twitter.com/brunowernimont
Apache License 2.0
265 stars 25 forks source link

[BKDynamicCellMapping] async assign image to cell using dynamic cell mapping #12

Closed angeloh closed 12 years ago

angeloh commented 12 years ago

If I have no image locally, and want to load image from Url. What can I do to assign the image in cell mapping's block?

[BKDynamicCellMapping mappingForObjectClass:[Item class] block:^(BKDynamicCellMapping *cellMapping) {
    [cellMapping mapKeyPath:@"imageUrl" toAttribute:@"imageView.image" valueBlock:^id(NSString *url) {
       // how to load image async here and assign to uiimage view
    }];
}];
brunow commented 12 years ago

First set the url [cellMapping mapKeyPath:@"imageURL" toAttribute:@"imageURL"];

After that, the mapper will call this method inside you cell view:

- (void)setImageURL:(NSString *)imageURL {
}