블로그 이미지
Sunny's

calendar

1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

Notice

2011. 10. 31. 16:37 IPhone

Block & GCD를 이용한 async 처리

dispatch_queue_t image_queue = dispatch_queue_create("image_que", NULL);

    dispatch_async(image_queue, ^{

        NSData *iconData = [NSData dataWithContentsOfURL:[NSURL URLWithString:selectedExample.iconPath]];

        _iconImageView.image = [UIImage imageWithData:iconData];

        

        // UI 메인 쓰레드에서 변경되어야 하므로...

        dispatch_async(dispatch_get_main_queue(), ^{

            _iconImageView.image = [UIImage imageWithData:iconData];

        });

    });




posted by Sunny's