reachability

Reachability Guide for iOS

[亡魂溺海] 提交于 2019-11-26 04:07:57
问题 Has anyone found a halfway decent guide to implementing Reachability on iOS? 回答1: I have implemented Reachability like this. Download https://developer.apple.com/library/content/samplecode/Reachability/Introduction/Intro.html and add Reachability.h and .m to your project. Add the SystemConfiguration framework to your project. #import "Reachability.h" where you want to use it. Use this code. -(BOOL)reachable { Reachability *r = [Reachability reachabilityWithHostName:@"enbr.co.cc"];

iPhone reachability checking

浪尽此生 提交于 2019-11-26 02:47:55
问题 I\'ve found several examples of code to do what I want (check for reachability), but none of it seems to be exact enough to be of use to me. I can\'t figure out why this doesn\'t want to play nice. I have the reachability.h/m in my project, I\'m doing #import <SystemConfiguration/SystemConfiguration.h> And I have the framework added. I also have: #import \"Reachability.h\" at the top of the .m in which I\'m trying to use the reachability. Reachability* reachability = [Reachability

iOS Detect 3G or WiFi

自闭症网瘾萝莉.ら 提交于 2019-11-26 01:46:36
问题 I am not sure if this is possible, but I have this scenario. I have a website displayed in my UIWebView which has the link set in a UISegmentedController. They website can detect if you are on wifi or on the 3g network. Now the segmented controller points to 2 different pages: 1 - An iPhone friendly login screen 2 - The home page, once you are logged in. Now here is the question: Can I program my application to detect whether it is to WIFI or 3G (I know you can do this), but then based on the

Easiest way to detect Internet connection on iOS?

一笑奈何 提交于 2019-11-26 00:50:01
问题 I know this question will appear to be a dupe of many others, however, I don\'t feel the simple case is well explained here. Coming from an Android and BlackBerry background, making requests through HTTPUrlConnection instantly fail if there is no connection available. This seems like completely sane behavior, and I was surprised to find NSURLConnection in iOS did not emulate it. I understand that Apple (and others who have extended it) provide a Reachability class to assist with determining

How to use SCNetworkReachability in Swift

对着背影说爱祢 提交于 2019-11-25 23:53:32
问题 I\'m trying to convert this code snippet to Swift. I\'m struggling on getting off the ground due to some difficulties. - (BOOL) connectedToNetwork { // Create zero addy struct sockaddr_in zeroAddress; bzero(&zeroAddress, sizeof(zeroAddress)); zeroAddress.sin_len = sizeof(zeroAddress); zeroAddress.sin_family = AF_INET; // Recover reachability flags SCNetworkReachabilityRef defaultRouteReachability = SCNetworkReachabilityCreateWithAddress(NULL, (struct sockaddr *)&zeroAddress);

How to check for an active Internet connection on iOS or macOS?

被刻印的时光 ゝ 提交于 2019-11-25 22:53:33
问题 I would like to check to see if I have an Internet connection on iOS using the Cocoa Touch libraries or on macOS using the Cocoa libraries. I came up with a way to do this using an NSURL . The way I did it seems a bit unreliable (because even Google could one day be down and relying on a third party seems bad), and while I could check to see for a response from some other websites if Google didn\'t respond, it does seem wasteful and an unnecessary overhead on my application. - (BOOL)

Check for internet connection with Swift

为君一笑 提交于 2019-11-25 22:48:00
问题 When I try to check for an internet connection on my iPhone I get a bunch of errors. Can anyone help me to fix this? The code: import Foundation import SystemConfiguration public class Reachability { class func isConnectedToNetwork() -> Bool { var zeroAddress = sockaddr_in() zeroAddress.sin_len = UInt8(sizeofValue(zeroAddress)) zeroAddress.sin_family = sa_family_t(AF_INET) let defaultRouteReachability = withUnsafePointer(&zeroAddress) { SCNetworkReachabilityCreateWithAddress(nil,

iOS Detect 3G or WiFi

安稳与你 提交于 2019-11-25 20:35:12
I am not sure if this is possible, but I have this scenario. I have a website displayed in my UIWebView which has the link set in a UISegmentedController. They website can detect if you are on wifi or on the 3g network. Now the segmented controller points to 2 different pages: 1 - An iPhone friendly login screen 2 - The home page, once you are logged in. Now here is the question: Can I program my application to detect whether it is to WIFI or 3G (I know you can do this), but then based on the answer go to segment 1 or 2 Kind of like this: if (iPhone device is on 3g) { Go to Segment 1; } else {