1

我已经被这个语义问题警告困扰了一个星期,而且变得令人沮丧。有人愿意看看吗?任何建议都将被亲切地采纳。<3

WebViewController.m

#import "WebViewController.h"
#import "Reachability.h"

@implementation WebViewController
@synthesize webView;
@synthesize backbtn;
@synthesize forwardbtn;
@synthesize webAddy;
@synthesize activityIndicator;
@synthesize loadingLabel;


- (void)viewDidLoad {
    loadingLabel.hidden = YES;
    backbtn.enabled = NO;
    forwardbtn.enabled = NO;
    webView.scalesPageToFit = YES;
    activityIndicator.hidesWhenStopped = YES;

    if([Reachability currentReachabilityStatus] == NotReachable)
{ 
        UIAlertView *av = [[[UIAlertView alloc] 
                            initWithTitle:@"Sorry" 
                            message:@"You are not connected to the internet. Please Try again"
                            delegate:nil 
                            cancelButtonTitle:@"OK"
                            otherButtonTitles:nil] autorelease];
        [av setDelegate:self];
        [av show];
    }
    else
    {
        NSURL *url = [NSURL URLWithString:webAddy];
        NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
        [webView loadRequest:requestObj];
    }

    [super viewDidLoad];
}

警告将我重定向到第 20 行。编译器告诉我:“找不到类方法‘+currentReachabilityStatus’(返回类型默认为‘id’)

如果需要更多信息,请告诉我。再次感谢大家!

4

2 回答 2

0

这里

- (NetworkStatus) currentReachabilityStatus;不是类方法。

于 2013-02-17T03:40:40.433 回答
0

使用[[Reachability reachabilityForInternetConnection] currentReachabilityStatus]而不是[Reachability currentReachabilityStatus].

currentReachabilityStatus是一个实例方法,所以你首先需要一个实例。

于 2013-02-17T03:40:42.310 回答