I want use subscriberCellularProviderDidUpdateNotifier in Swift, but I don't know how and where it can be placed.
Any ideas? I have searched for that, but only Objective-C samples are available.
In Objective C you just need to use "set" and the name of the property block while in Swift you need to assign it:
// Declare your class member
let networkInfo = CTTelephonyNetworkInfo();
// In viewDidLoad or in your custom method
networkInfo.subscriberCellularProviderDidUpdateNotifier = { carrier in
// Do whatever you wanna do when a callback comes
}
carrier will be of type CTCarrier
.
Of course, you can always use the $0 which refers to CTCarrier
argument:
networkInfo.subscriberCellularProviderDidUpdateNotifier = {
$0
// Do whatever you need to do with it
}
and it looks a lot more cleaner.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With