Can someone please help me how I can get the Data Usage from WWAN and WLAN with Swift?
I found on Stack Overflow how to do that in Objective-C but an explanation would be nice!
Can someone please help me how I can get the Data Usage from WWAN and WLAN with Swift?
I found on Stack Overflow how to do that in Objective-C but an explanation would be nice!
Swift 4
Sample Usage
Code
Old Version
Here's one possible implementation.
First, include
ifaddrs
in your Objective-C bridging header:Then, try out this function:
It returns nested Swift tuples representing the four pieces of data you requested. This makes it easy to access. For example:
Updated @Aaron Brager answer for Swift 4 and Xcode 9.