我在使用 Apple 的可达性类时遇到问题。我从 AppDelate 成功使用它,但是当我尝试从另一个视图控制器类中使用它时,我收到下面的警告,尽管它仍然有效。任何帮助表示赞赏。lq
// MyViewController.m
#import "Reachability.h"
- (void) viewDidLoad {
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(reachabilityChangedState:)
name: kReachabilityChangedNotification
object: nil];
}
- (void) reachabilityChangedState: (NSNotification* )note {
// Called by Reachability whenever status changes
Reachability* curReach = [note object];
NSParameterAssert([curReach isKindOfClass: [Reachability class]]);
// HERE I GET THE FOLLOWING WARNING: 'MyViewController' may not respond to '-updateViewWithReachability.'
[self updateViewWithReachability: curReach];
}
- (void) updateViewWithReachability: (Reachability*) curReach {
... // do my thing with controls
}