0

我正在使用 Apple 提供的 Rechablity.h 和 Rechablity.h 并使用这些文件并添加了一些代码,例如

#pragma mark Rechability method

/**
* reachabilityChanged()
* @desc Check the internet connection
* @param NSNotification note is the notification of internet state changed
*/

- (void) reachabilityChanged: (NSNotification* )note {

Reachability* curReach = [note object];
NSParameterAssert([curReach isKindOfClass: [Reachability class]]);
[self updateInterfaceWithReachability: curReach];
}

/**
* updateInterfaceWithReachability()
* @desc Update the internet connection state
* @param Reachability curReach is the instance of Reachbility
*/

- (void) updateInterfaceWithReachability: (Reachability*) curReach {

if(curReach == internetReach) {

    NetworkStatus netStatus = [curReach currentReachabilityStatus];
    BOOL connectionRequired = [curReach connectionRequired];
    NSString* statusString = @"";

    switch (netStatus) {

        case NotReachable: {

            statusString = @"Access Not Available";
            connectionRequired = NO;
            isInternetAvailable = FALSE;
            break;
        }

        case ReachableViaWWAN: {

            statusString = @"Reachable WWAN";
            isInternetAvailable = TRUE;
            break;
        }

        case ReachableViaWiFi: {

            statusString = @"Reachable WiFi";
            isInternetAvailable = TRUE;
            break;
        }
    }

    if(connectionRequired)
        statusString = [NSString stringWithFormat: @"%@, Connection Required", statusString];
    //UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Gmmabling Gambit" message:statusString delegate:nil cancelButtonTitle:nil otherButtonTitles:@"Ok",nil];
    //      [alert show];
    //      [alert release];
    //NSLog(@"%@",statusString);
}
}

/**
* internetCheck()
* @desc store the internet connection state
* @return BOOL internet is available or not
*/

- (BOOL)internetCheck {

return isInternetAvailable;
}

添加了 systemConfiguration.framework 和 Security.framework 但出现此类错误

clang: error: linker command failed with exit code 1 (use -v to see invocation)
4

2 回答 2

0

当您没有.m filebundle resources. 所以你可以交叉检查这些文件是否被添加或者添加实现文件。您可以通过转到Build Phases -> Compile resources 然后添加 .m 文件来执行相同操作

让我知道它是否有效:)

希望这可以帮助!

于 2013-02-09T12:28:00.683 回答
0

在构建设置中,使用构建架构搜索,如果该值为否,则替换为是。可能是作品。您必须同时更改项目和目标。

于 2013-02-09T13:06:02.303 回答