0
我已經添加了一個來自AppDelegate
的觀察者,並將此代碼放入didFinishLaunchingWithOptiong
方法中。NSObject的NSNotificationCenter addObserver來自NSObject的子類
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reachabilityChanged:) name:kReachabilityChangedNotification object:nil];
internetReachability = [Reachability reachabilityForInternetConnection];
[internetReachability startNotifier];
現在我想把這個addObserver
我的自定義類是NSObject
一個子類裏面?
編輯:
這是我reachabilityChanged方法:
- (void) reachabilityChanged:(NSNotification *)note
{
NSLog(@"change");
}
我把這個方法在我稱之爲的addObserver
問題是什麼? –
reachabilityChanged方法沒有命中,如果我把它放在NSObject的子類上@Rage – indraep
'reachabilityChanged:'選擇器在哪裏定義?在AppDelegate中? –