gpt4 book ai didi

iphone - 从苹果复制了可达性测试,但链接器失败

转载 作者:行者123 更新时间:2023-12-03 16:06:57 27 4
gpt4 key购买 nike

我尝试使用苹果发布的可达性项目来检测自己示例中的可达性。我复制了大部分初始化,但我在链接器中遇到此失败:

Ld build/switchViews.build/Debug-iphoneos/test.build/Objects-normal/armv6/test normal armv6
cd /Users/uid04100/Documents/TEST
setenv IPHONEOS_DEPLOYMENT_TARGET 3.1.3
setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 -arch armv6 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.3.sdk -L/Users/uid04100/Documents/TEST/build/Debug-iphoneos -F/Users/uid04100/Documents/TEST/build/Debug-iphoneos -filelist /Users/uid04100/Documents/TEST/build/switchViews.build/Debug-iphoneos/test.build/Objects-normal/armv6/test.LinkFileList -dead_strip -miphoneos-version-min=3.1.3 -framework Foundation -framework UIKit -framework CoreGraphics -o /Users/uid04100/Documents/TEST/build/switchViews.build/Debug-iphoneos/test.build/Objects-normal/armv6/test

Undefined symbols:
"_SCNetworkReachabilitySetCallback", referenced from: -[Reachability startNotifer] in Reachability.o
"_SCNetworkReachabilityCreateWithAddress", referenced from: +[Reachability reachabilityWithAddress:] in Reachability.o
"_SCNetworkReachabilityScheduleWithRunLoop", referenced from: -[Reachability startNotifer] in Reachability.o
"_SCNetworkReachabilityGetFlags", referenced from: -[Reachability connectionRequired] in Reachability.o -[Reachability currentReachabilityStatus] in Reachability.o
"_SCNetworkReachabilityUnscheduleFromRunLoop", referenced from: -[Reachability stopNotifer] in Reachability.o
"_SCNetworkReachabilityCreateWithName", referenced from: +[Reachability reachabilityWithHostName:] in Reachability.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

我的委托(delegate).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

我的代表.m:

#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

最佳答案

算了。我只是不知道我必须手动添加系统配置框架。我以为导入的时候就加上了。

关于iphone - 从苹果复制了可达性测试,但链接器失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2788354/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com