Develop

[ios] GCD 변수 사용 예제

by hooni posted Oct 01, 2013
?

단축키

Prev이전 문서

Next다음 문서

ESC닫기

크게 작게 위로 아래로 댓글로 가기 인쇄

블럭코드 변수 사용 예제.


@implementation UIImageView (AFNetworkingCustom)
- (void)setImageWithURL:(NSURL *)url
       placeholderImage:(UIImage *)placeholderImage
           gaussianBlur:(BOOL)filter
{
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
    [request addValue:@"image/*" forHTTPHeaderField:@"Accept"];
    
    if(filter){
        //가우시안필터
        void (^block)
        (NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) =
        ^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image){
            [self setImage:[image imageWithGaussianBlur]];
        };
        
        [self setImageWithURLRequest:request
            placeholderImage:placeholderImage success:block failure:nil];
    }else{
        [self setImageWithURLRequest:request
            placeholderImage:placeholderImage success:nil failure:nil];
    }
}
@end