开发者

Warning Received When Using Reachability

I'm having a problem with Apple's Reachability class. I use it successfully from the AppDelate, but when I try to use it from another view controller class I get the warning below, though it still works. Any help is appreciated. 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 contr开发者_Python百科ols
}


I think you will have to place the method above, not below, the reachabilityChangedState method to have it recognized.

If that doesn't help, try placing the following in the .h file:

-(void) updateViewWithReachability: (Reachability*) curReach;

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜