2

私は単純な関数を書き、コンパイラを渡しますが、リンカは渡しません。

理由はありますか?

- (BOOL) connectedToWifi
{

    CFArrayRef myArray = CNCopySupportedInterfaces();
    // Get the dictionary containing the captive network infomation
    CFDictionaryRef captiveNtwrkDict = CNCopyCurrentNetworkInfo(CFArrayGetValueAtIndex(myArray, 0));

    NSLog(@"Information of the network we're connected to: %@", captiveNtwrkDict);

    NSDictionary *dict = (__bridge NSDictionary*) captiveNtwrkDict;
    NSString* ssid = [dict objectForKey:@"SSID"];

    if ([ssid rangeOfString:@"WXYZ"].location == NSNotFound || ssid == NULL)
    {
        return false;
    }
    else
    {
        return true;
    }
}

これは私が得るエラーです:

Undefined symbols for architecture i386:
  "_CNCopySupportedInterfaces", referenced from:
      -[miApp_funcs connectedToWifi] in miApp_funcs.o
  "_CNCopyCurrentNetworkInfo", referenced from:
      -[miApp_funcs connectedToWifi] in miApp_funcs.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
4

2 に答える 2

4

以下は手順です-

1) ナビゲーターエリアでプロジェクトをクリック

2) 「ターゲット」タブを選択

3) [ビルド フェーズ] をクリックします。

4) [バイナリをライブラリにリンク] を選択します。

5) 次に、領域の下部に「+」ボタンが表示されます。必要な SystemConfiguration フレームワークを追加できるようになりました。

#import <SystemConfiguration/SystemConfiguration.h>
于 2012-09-03T18:18:19.983 に答える
3

#import <SystemConfiguration/SystemConfiguration.h>キャプティブ ネットワーク (CN) のクラスと機能にアクセスするには、 と にリンクする必要があります。

于 2012-05-30T02:37:38.510 に答える