Iphone 从apple复制了可达性测试,但链接器给出了一个失败
我曾尝试使用苹果公司发布的可达性项目在自己的示例中检测可达性。我复制了most初始化,但在链接器中出现以下故障: 未定义的符号:Iphone 从apple复制了可达性测试,但链接器给出了一个失败,iphone,cocoa,reachability,Iphone,Cocoa,Reachability,我曾尝试使用苹果公司发布的可达性项目在自己的示例中检测可达性。我复制了most初始化,但在链接器中出现以下故障: 未定义的符号: “\u SCNetworkReachabilitySetCallback”, 引用自: -可达性中的[可达性启动通知]o “\u SCNetworkReachabilityCreateWithAddress”, 引用自: +[Reachability-reachabilityWithAddress:]位于 可达性.o “\u SCNetworkReachability
“\u SCNetworkReachabilitySetCallback”, 引用自: -可达性中的[可达性启动通知]o
“\u SCNetworkReachabilityCreateWithAddress”, 引用自: +[Reachability-reachabilityWithAddress:]位于 可达性.o
“\u SCNetworkReachabilityScheduleWithRunLoop”, 引用自: -可达性中的[可达性启动通知]o
“\u SCNetworkReachabilityGetFlags”, 引用自: -可达性中的[Reachability connectionRequired] -[Reachability currentReachabilityStatus]位于 可达性.o
“\u SCNetworkReachabilityUnscheduleFromRunLoop”, 引用自: -可达性中的[Reachability stopNotifer]o
“\u SCNetworkReachabilityCreateWithName”,引用自: +[Reachability Reachability with hostname:]位于 可达性.o
ld:找不到符号
collect2:ld返回了1个退出状态 我的代表。h:
#import <UIKit/UIKit.h>
@class Reachability;
@interface testAppDelegate : NSObject
<UIApplicationDelegate> { UIWindow
*window; UINavigationController *navigationController;
Reachability* hostReach;
Reachability* internetReach;
Reachability* wifiReach;
}
@property (nonatomic, retain) IBOutlet
UIWindow *window; @property
(nonatomic, retain) IBOutlet
UINavigationController
*navigationController;
@end
算了吧。我只是不知道我必须手动添加systemconfiguration框架。我以为在导入时会添加它。您不需要导入框架;您可以导入标题。如您所见,将头导入源文件不会将框架添加到项目或目标中。是的,添加SystemConfiguration.framework将解决此问题。
#import <UIKit/UIKit.h>
@class Reachability;
@interface testAppDelegate : NSObject
<UIApplicationDelegate> { UIWindow
*window; UINavigationController *navigationController;
Reachability* hostReach;
Reachability* internetReach;
Reachability* wifiReach;
}
@property (nonatomic, retain) IBOutlet
UIWindow *window; @property
(nonatomic, retain) IBOutlet
UINavigationController
*navigationController;
@end
#import "testAppDelegate.h"
#import "SecondViewController.h"
#import "Reachability.h"
@implementation testAppDelegate
@synthesize window; @synthesize
navigationController;
- (void) updateInterfaceWithReachability:
(Reachability*) curReach {
if(curReach == hostReach) {
BOOL connectionRequired= [curReach connectionRequired];
if(connectionRequired)
{ //in these brackets schould be some code with sense, if i´m getting it to run
}
else
{
}
} if(curReach == internetReach) { } if(curReach == wifiReach) {
} }
//Called by Reachability whenever
status changes.
- (void) reachabilityChanged: (NSNotification* )note {
Reachability* curReach = [note
object]; NSParameterAssert([curReach
isKindOfClass: [Reachability class]]);
[self
updateInterfaceWithReachability:
curReach]; }
- (void)applicationDidFinishLaunching:(UIApplication
*)application {
// Override point for customization after application launch
// Observe the
kNetworkReachabilityChangedNotification.
When that notification is posted, the
// method "reachabilityChanged" will be called. //
[[NSNotificationCenter defaultCenter]
addObserver: self selector:
@selector(reachabilityChanged:) name:
kReachabilityChangedNotification
object: nil];
//Change the host name here to change the server your monitoring
hostReach = [[Reachability
reachabilityWithHostName:
@"www.apple.com"] retain]; [hostReach
startNotifer]; [self
updateInterfaceWithReachability:
hostReach];
internetReach = [[Reachability reachabilityForInternetConnection]
retain]; [internetReach
startNotifer]; [self
updateInterfaceWithReachability:
internetReach];
wifiReach = [[Reachability reachabilityForLocalWiFi] retain];
[wifiReach startNotifer]; [self
updateInterfaceWithReachability:wifiReach];
[window addSubview:[navigationController
view]];
[window makeKeyAndVisible]; }
- (void)dealloc { [navigationController release];
[window release];
[super dealloc]; }
@end