Below snippet is used to fetch SSID of current network.
__block NSString *ssid = nil;
dispatch_semaphore_t sem = dispatch_semaphore_create(0);
[NEHotspotNetwork fetchCurrentWithCompletionHandler:^(NEHotspotNetwork * _Nullable currentNetwork) {
if( currentNetwork != nil) {
ssid = [currentNetwork SSID];
}
dispatch_semaphore_signal(sem);
}];
We are getting proper currentNetwork information in the block. But when ssid is fetched from outside the block, it is getting invalid after the block exits. We are getting bad NSString object.
This issue occurs only on iOS 15.5 beta version or later. Same code snippet worked perfectly for earlier versions of iOS.
Can you help why it occurs only on iOS 15.5 or later versions?
Note: Requirement according to https://developer.apple.com/forums/thread/679038 is fulfilled