嗨,我正在寻找一个简单的代码来读取SSID,我找到了很多关于"SystemConfiguration/CaptiveNetwork.h"的信息但是我怎么能使用它,我不明白。对不起,我是一个新的Objective-C程序员。您是否有一个很好的例子或教程来理解它。我尝试了来自Apple的Reachable,但它们不适用于字典。
感谢您的帮助
谢谢@helming,在这里,这样它就不会编译成模拟器二进制文件+添加对CFRelease的调用:
#if !TARGET_IPHONE_SIMULATOR
CFArrayRef interfaces = CNCopySupportedInterfaces();
CFDictionaryRef networkInfo = CNCopyCurrentNetworkInfo(CFArrayGetValueAtIndex(interfaces, 0));
NSString *ssid = CFDictionaryGetValue(networkInfo, @"SSID");
CFRelease(interfaces);
CFRelease(networkInfo);
#endif
CFArrayRef myArray = CNCopySupportedInterfaces();
CFDictionaryRef myDict = CNCopyCurrentNetworkInfo(CFArrayGetValueAtIndex(myArray, 0));
NSString *ssid = CFDictionaryGetValue(myDict, @"SSID");