현재 접근 가능성을 확인해야하는 앱을 만들고 있습니다.도달 가능성 코드가 메인 스레드를 차단하고 있습니다.
이로 인해 필자는 물건을 찾기 시작했고 DDG와 Apple 코드를 발견했습니다. Apple의 최신 도달 코드를 사용하기로 결정했습니다.
는 그 수입, 애플의 샘플에서 제안, 나는 등록하기 위해 다음과 같은 방법으로 내놓았다 :이 코드는 UI를 차단하기 시작하는 응용 프로그램이 있었다 실행했을 때 내가 관찰 무엇[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notificationHandler:) name:kReachabilityChangedNotification object:nil];
//check for local connection and start notifier
client = [[Reachability reachabilityForInternetConnection] retain];
[client startNotifier];
//check for server connection and start notifier
server = [[Reachability reachabilityWithHostName:SERVER_HOST_NAME] retain];
[server startNotifier];
//check for other server and start notifier
otherServer = [[Reachability reachabilityWithHostName:OTHER_SERVER_HOST_NAME] retain];
[otherServer startNotifier];
(차단 메인 스레드). 호스트 이름이 해결 될 때까지 다른 UI 요소와 상호 작용할 수 없었습니다. 이제 Apple이 DNS 확인 및 비동기 작성에 대한 경고를 발표했음을 알고 있습니다.
제 질문은 어떻게하면 비동기로 만들 수 있습니까?
다른 스레드를 생성하고 Reachability 객체를 "릴리스"하지 않도록 계속 실행합니까?
미리 도움 주셔서 감사합니다. :)
해결 방법은 무엇입니까? –