开发者

How can I get the iPhone's current network speed?

I want to get the iPhone's network speed so that I can give user an info when the开发者_如何转开发 speed is too slow.


Remember, the iPhone is a wireless device, and likely on the move. The network speed can (and will) vary drastically from moment to moment, so measure average throughput over at least 20 seconds or so... that's basically how the "bars" work. If they were updated in real time, they would be bouncing all over the place.


Net speed is gonna vary radically depending on a huge passel of variables between the iPhone and whatever server you are trying to connect to.

You are far better off adapting your behavior on the fly based on whatever data flow rate you happen to be enjoying at any given time.

Kinda like how Netflix automatically adjusts video quality as the network connection quality changes over time.


In the ZDS_Shared cache they put each download operation on a NSOperation and then calculate based on size and time. See calculateBandwidthForDelegate:. Then they set one of three possible network states and throttle downloads accordingly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜