0
我得到這個錯誤:可達無可見@interface聲明選擇startNotifier可達性無可見@interface聲明選擇startNotifier
我既包括Reachability.h和.m文件。 我對Objective-C非常陌生,錯誤可能非常小!但任何幫助將是偉大的!
我helloworldViewController.m
#import "helloworldViewController.h"
#import "Reachability.h"
#import <SystemConfiguration/SystemConfiguration.h>
@interface helloworldViewController()
@end
@implementation helloworldViewController
@synthesize networkstatus;
@synthesize reach;
#pragma mark Reachability changed
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
// Check network
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reachabilityChanged:) name:kReachabilityChangedNotification object:nil];
self.reach = [Reachability reachabilityWithHostName:@"www.apple.com"];
[self.reach startNotifer];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)reachabilityChanged:(NSNotification*)note
{
Reachability* r = [note object];
NetworkStatus ns = r.currentReachabilityStatus;
if (ns == NotReachable)
{
NSString* msg = @"Network problems have rendered the iTunes store inaccessible; please try again later.";
UIAlertView* av = [[UIAlertView alloc] initWithTitle:nil
message:msg
delegate:self
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[av show];
//[av release];
}
}
@end
,這裏是我的helloworldViewController.h
#import <UIKit/UIKit.h>
#import "Reachability.h"
@interface helloworldViewController : UIViewController{
Reachability* reach;
IBOutlet UILabel *networkstatus;
}
@property(strong,nonatomic) UILabel *networkstatus;
@property (nonatomic, retain) Reachability* reach;
@end
嘿!非常感謝你。 :D – megZo
不客氣。查看我更新的答案並提供更多建議。 – rmaddy
輝煌!謝謝 :) – megZo