You can make use of CNCopySupportedInterfaces() call.
CFArrayRef interfaces = CNCopySupportedInterfaces();
CFIndex count = CFArrayGetCount(interfaces);
for (int i = 0; i < count; i++) {
CFStringRef interface = CFArrayGetValueAtIndex(interfaces, i);
CFDictionaryRef netinfo = CNCopyCurrentNetworkInfo(interface);
if (netinfo && CFDictionaryContainsKey(netinfo, kCNNetworkInfoKeySSID)) {
NSString *ssid = (__bridge NSString *)CFDictionaryGetValue(netinfo, kCNNetworkInfoKeySSID);
// Compare with your needed ssid here
}
if (netinfo)
CFRelease(netinfo);
}
CFRelease(interfaces);
In my experience, you will usually have one interface in the array which would either be a valid structure if you're connected or NULL
if you're not. Still I let the for loop be there just in case.
The __bridge
cast inside is only needed if you're using ARC.