In Objective-C, you just need to use "set" and the name of the property block, while in Swift you need to assign it:
let networkInfo = CTTelephonyNetworkInfo();
networkInfo.subscriberCellularProviderDidUpdateNotifier = { carrier in
}
the carrier will be of type CTCarrier.
Of course, you can always use $ 0, which refers to the argument CTCarrier:
networkInfo.subscriberCellularProviderDidUpdateNotifier = {
$0
// Do whatever you need to do with it
}
and it looks a lot cleaner.
source
share