1
네트워크 상태가 변경 될 때 알림을 받아야합니다. 나는 이미 other topic에서 네트워크 도달 가능성을 확인하는 방법을 찾았습니다.네트워크 상태 변경 알림
내가 할 수있는 대리인이 있습니까?
네트워크 상태가 변경 될 때 알림을 받아야합니다. 나는 이미 other topic에서 네트워크 도달 가능성을 확인하는 방법을 찾았습니다.네트워크 상태 변경 알림
내가 할 수있는 대리인이 있습니까?
Apple's Reachability sample project의 코드를 사용한다고 가정하면 kReachabilityChangedNotification
알림에 등록하려고합니다.
let nc = NSNotificationCenter.defaultCenter();
nc.addObserver(self, selector:"handleReachabilityChanged:", name:kReachabilityChangedNotification, object:nil);
가 NSNotificationCenter를 참조하십시오
func handleReachabilityChanged(notification:NSNotification)
{
// notification.object will be a 'Reachability' object that you can query
// for the network status.
NSLog("Network reachability has changed.");
}
그런 다음이 같이 당신의 UIViewController의 viewDidLoad()
방법에 그 통지를 등록 할 수 있습니다 :
당신이 방법이있는 UIViewController 하위를 가정 알림 처리기를 설정하고 해체하는 방법은 NSNotification 설명서를 참조하십시오.