activeSlices
Information about currently active network slices on the device.
Declaration
final var activeSlices: [CTSlicingManager.Slice] { get async throws }Return Value
An array of CTSlicingManager.Slice structures, each containing appCategory, trafficClass, and networkInterfaceName.
Discussion
This property returns an array of CTSlicingManager.Slice structures containing detailed information about each active network slice, including the app category, traffic class, and network interface name.
Use this property to monitor which network slices currently run, and to validate that your preferred slice activates successfully.
do {
let slices = try await CTSlicingManager.shared.activeSlices
for slice in slices {
print("Active slice:")
print(" Category: \(slice.appCategory.description)")
print(" Traffic Class: \(slice.trafficClass.description)")
print(" Interface: \(slice.networkInterfaceName)")
}
} catch POSIXError.ENOTSUP {
print("Network slicing isn't currently available.")
} catch {
print("Error retrieving active slices: \(error)")
}