GCD使えば非同期通信系が簡単に書けるので試してみた。
-(void)loadImageGCD :(UIImageView *)iv :(CGRect)rect :(NSString *)url{
dispatch_queue_t q_global = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_queue_t q_main = dispatch_get_main_queue();
iv.frame = rect;
dispatch_async(q_global, ^{
NSString *imageUrl = url;
UIImage *image1 = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:imageUrl]]];
dispatch_async(q_main, ^{
iv.image = image1;
});
});
}
これで引数のUIImageViewをaddChildとかしておけば、UIImageがよみこまれたら、そこに表示されます。