Network Connection Warning
The Tweetie (now Twitter) app has a pop up Network Reachability warning. This also done in the Foursquare and Hashable apps (as far as I know). Is there example code of this implementa开发者_StackOverflowtion somewhere? Thanks.
The apple recommended way is decently documented here (a bit old): http://www.raddonline.com/blogs/geek-journal/iphone-sdk-testing-network-reachability/
The AllSeeingInteractive ASIHTTPrequest library integrates an extended version of this by Andrew Donoho as a drop-in replacement for Apple’s Reachability class. It allows ASIHTTPRequest to be notified when the network connection changes from WWAN to WiFi, or vice-versa. It uses an NSNotificationCenter observer to watch for network connectivity changes.
ASIHTTPRequest is available from github at http://github.com/pokeb/asi-http-request/tree, the doucmentation is at http://allseeing-i.com/ASIHTTPRequest/
The request library is worth a look in as well, if you need one - I use it in all my iOS / Mac projects that call out to the Internet.
精彩评论