Measure network traffic programmatically on iPhone
I'm interested in mea开发者_如何学运维suring the network traffic for my application. Ideally I would need to separate wireless from 3G network traffic. I can't seem to find any API that gets this information; however I see that there is at least one app in the AppStore that does something close (they actually sum up the traffic for the entire phone).
Any ideas?
I've found one approximate solution: getifaddrs
can be used to get statistics on network usage.
One advantage is that it can get separate statistics for Wi-Fi and WWAN interfaces.
A disadvantage is that on multi-tasking devices those interfaces may be used by multiple applications and the statistics are cumulated.
I also was looking for solution and found it here: iPhone Data Usage Tracking/Monitoring
Please take a look this post, it provides all info that you need.
精彩评论