Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialivan hernandez
Courses Plus Student 2,298 PointsIOS7 Get SSID and BSSid
I´m having problems getting SSID, I´m using this code but I don't get anything ...
-(void)getCurrentWifi{
(NSString *)GetCurrentWifiHotSpotName{
NSString *wifiname = nil;
NSArray *ifs = (__bridge_transfer id)CNCopySupportedInterfaces();
for (NSString *ifnam in ifs) {
NSDictionary *info = (__bridge_transfer id)CNCopyCurrentNetworkInfo((__bridge CFStringRef)ifnam);
NSLog(@"informacion: %@", info);
if (info[@"SSID"]) {
wifiname = info[@"SSID"];
}
}
Ben Jakuben , Amit Bijlani , any tips??? what is wrong with this code???
thx
4 Answers
Stefan Jansen
8,974 PointsI use this code, it works like a charm. :)
- (NSString *)getCurrentWiFiName
{
NSString *ssid = @"NO WIFI!";
NSArray *ifs = (__bridge_transfer id)CNCopySupportedInterfaces();
if ([ifs count] > 0) {
for (NSString *ifname in ifs) {
NSDictionary *info = (__bridge_transfer id)CNCopyCurrentNetworkInfo((__bridge CFStringRef)ifname);
if (info[@"SSID"]) {
ssid = info[@"SSID"];
}
}
}
return ssid;
}
ivan hernandez
Courses Plus Student 2,298 PointsHi there, I used that code but I get IFS=null ... But I guess the problems is with the simulardor I need to try it in phone to see what happens
Amit Bijlani
Treehouse Guest TeacherI've never had to do this so I'll point you to this answer on Stack Overflow: http://stackoverflow.com/questions/5198716/iphone-get-ssid-without-private-library
ivan hernandez
Courses Plus Student 2,298 PointsAmit,
Thank you for you answer.