2010-08-10 2 views
0

많은 광고를 사용하지 않는 사과 금지 플래시가 있지만. 나는 아직도 브라우저를위한 기능처럼 adblock을 좋아한다.UIWebview에 대한 adblock을 수행하는 방법은 무엇입니까?

모든로드 요청의 URL을 확인하여 adblock이이를 감지했습니다. UIWebview에서 가능합니까? nil을 반환하는 것을

static id (*oldMethod)(id self, SEL _cmd, NSURL* theURL, ....); 

static id newMethod(id self, SEL _cmd, NSURL* theURL, ....) { 
    if ([[theURL absoluteString] hasPrefix:@"http://example.com"]) { 
     [self release]; 
     return nil; 
    } 
    return oldMethod(self, _cmd, theURL, cachePolicy, timeoutInterval); 
} 

.... 


Method m = class_getInstanceMethod([NSURLRequest class], 
            @selector(initWithURL:cachePolicy:timeoutInterval:)); 
oldMethod = method_setImplementation(m, newMethod); 

참고 :

어떤 제안이 잘

그러나 감사

답변

1

번호를 제공, 당신이 요청을 방지하기 위해 swizzle-[NSURLRequest initWithURL:cachePolicy:timeoutInterval:]는 처음부터 예를 발행 할 수 있습니다 일반적으로 안전하지 않습니다. 요청이 일부 데이터 구조에 저장되고 프로그램이 중단 될 수 있습니다.

관련 문제