2012-01-02 2 views
1

저는 성공적으로 AsiHttpRequest 라이브러리를 사용하여 내 응용 프로그램에서 URL 연결을 만듭니다. 그러나, 나는 약간의 오차가보고 iOS5를하고 Reachability.m 파일로 업그레이드 (4) 다음과 같은 기능에 :iOS5에서 asiHttpRequest

static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void* info) { 

    #pragma unused (target, flags) 
    NSCAssert(info, @"info was NULL in ReachabilityCallback"); 
    NSCAssert([(NSObject*) info isKindOfClass: [Reachability class]], @"info was the wrong class in ReachabilityCallback"); 


    // Post a notification to notify the client that the network reachability changed. 
    [[NSNotificationCenter defaultCenter] postNotificationName: kReachabilityChangedNotification object: (Reachability *) info]; 


} // ReachabilityCallback() 


- (BOOL) startNotifier { 

    SCNetworkReachabilityContext context = {0, self, NULL, NULL, NULL}; 

    if(SCNetworkReachabilitySetCallback(reachabilityRef, ReachabilityCallback, &context)) { 

     if(SCNetworkReachabilityScheduleWithRunLoop(reachabilityRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode)) { 

      return YES; 

     } 

    } 

    return NO; 

} // startNotifier 

1SR 오류 : NSCAssert 라인에서, "C 포인터 타입 캐스트 '무효'목표 - C 포인터 NSObject 유형은 브릿지 된 캐스트가 필요합니다. " 왜 그런 일이 일어나고 어떻게 해결할 수 있습니까?

답변 : 각 파일에 대해 ARC를 사용 중지 할 수 있습니다. 프로젝트의 설정을 빌드하고 모든 ASIHTTPRequest 파일에서 -fno-objc-arc 플래그를 설정하십시오 (텍스트 편집을 위해 더블 클릭). 그런 다음 ASIAuthenticationDialog와 여전히 오류를 생성하는 참조를 제거해야합니다. 그것은 나를 위해 작동합니다.

+0

내 대답은 비슷한 문제를 가진 사람들을 돕기 위해 집중된다

어쨌든,이처럼 내 Reachability.m에서 그 선이 보일 것입니다. -1이라면 최소한 이유를 설명하십시오. 감사합니다 – Jaume

답변

2

편집 : 지금 기억하고 있습니다. 문제는 아크입니다. 그러나 빌드 단계 >> 컴파일 소스 : -fno-objc-arc에 다음 컴파일러 플래그를 설정하여 ARC에서 파일을 제외 할 수 있습니다. 모든 ASIHTTPRequest 파일을 선택하고 두 번 클릭하면 모든 파일에 대한 플래그를 하나씩 설정할 수 있습니다.

ORIGINAL POST : 지금 주 동안 ASIHTTPRequest을 사용하고 내가 도달 가능성 문제에 대해 어딘가에 게시물을 읽고 기억

, 난 그냥 정확히 무엇인지 기억할 수 없습니다.

//Start listening for reachability notifications on the current run loop 
static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void* info) { 

#pragma unused (target, flags) 
NSCAssert(info, @"info was NULL in ReachabilityCallback"); 
NSCAssert([(NSObject*) info isKindOfClass: [Reachability class]], @"info was the wrong class in ReachabilityCallback"); 

//We're on the main RunLoop, so an NSAutoreleasePool is not necessary, but is added defensively 
// in case someone uses the Reachablity object in a different thread. 
NSAutoreleasePool* pool = [NSAutoreleasePool new]; 

// Post a notification to notify the client that the network reachability changed. 
[[NSNotificationCenter defaultCenter] postNotificationName: kReachabilityChangedNotification 
                object: (Reachability *) info]; 

[pool release]; 

} // ReachabilityCallback() 


- (BOOL) startNotifier { 

    SCNetworkReachabilityContext context = {0, self, NULL, NULL, NULL}; 

    if(SCNetworkReachabilitySetCallback(reachabilityRef, ReachabilityCallback, &context)) { 

     if(SCNetworkReachabilityScheduleWithRunLoop(reachabilityRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode)) { 

      return YES; 

     } 

    } 

    return NO; 

} // startNotifier 
+0

내가 사용하고있는 코드와 동일하지만 작동하지 않습니다. ARC 때문에 문제가 발생했습니다. – Jaume