Question

Hi I am Looking for a Simple Code to read the SSID, I found a lot of Information about "SystemConfiguration/CaptiveNetwork.h" but how can I use it, i don't understand it. Sorry I am a new Objective-C programmer. Do you have a good example or tutorial to understand it. I tried Reachable from Apple but they don't work with Dictionaries.

Thanks for help

Was it helpful?

Solution

Thank you @helming, here it is, this way it won't compile into the Simulator binary + added calls to CFRelease:

#if !TARGET_IPHONE_SIMULATOR
    CFArrayRef interfaces = CNCopySupportedInterfaces();
    CFDictionaryRef networkInfo = CNCopyCurrentNetworkInfo(CFArrayGetValueAtIndex(interfaces, 0));
    NSString *ssid = CFDictionaryGetValue(networkInfo, @"SSID");
    CFRelease(interfaces);
    CFRelease(networkInfo);
#endif

OTHER TIPS

CFArrayRef myArray = CNCopySupportedInterfaces();
CFDictionaryRef myDict = CNCopyCurrentNetworkInfo(CFArrayGetValueAtIndex(myArray, 0));
NSString *ssid = CFDictionaryGetValue(myDict, @"SSID");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top