reachability

Reachability change notification should be called only once

依然范特西╮ 提交于 2019-12-10 16:06:28
问题 I'm using Reachability in my swift project. I had below code in AppDelegate NSNotificationCenter.defaultCenter().addObserver(self, selector: "reachabilityChanged:", name: ReachabilityChangedNotification, object: reachability) reachability.startNotifier() It does call func reachabilityChanged(note: NSNotification) { } But my problem is that, it is being called for all the request. That is, I'm loading images from the server, so when network reachability get's change this is method get's call

Reachability reachabilityWithAddress does not work

社会主义新天地 提交于 2019-12-10 15:08:18
问题 I am trying to determine if the iphone can connect to my IP address using following code struct sockaddr_in server_address; server_address.sin_len = sizeof(server_address); server_address.sin_family = AF_INET; server_address.sin_port = htons(8888); server_address.sin_addr.s_addr = inet_addr("1.2.3.4"); Reachability *r = [[Reachability reachabilityWithAddress:&server_address ] retain]; NetworkStatus internetStatus = [r currentReachabilityStatus]; But it always says that the status is

Detect wifi enabled (regardless of whether it's connected)

一世执手 提交于 2019-12-10 12:58:23
问题 For a GPS tracking app, recording location signals with WIFI turned on results in really imprecise data or data with gaps. I've used the Reachability queries to detect if wifi is available prior to starting tracking. The problem is that if when that query is made the wifi is enabled but not connected to a network, it shows that the internet is not reachable via wifi, but that's not an indication of if the setting is disabled in the settings app. This means that if the user starts running and

iPhone Reachable classes

时光总嘲笑我的痴心妄想 提交于 2019-12-10 11:04:43
问题 I have added the two files Reachability.h/m. The problem I am having is in the ReachabilityCallback method NSCAssert([(NSObject*) info isKindOfClass: [Reachability class]], @"info was wrong class in ReachabilityCallback"); The error message is: Cast of C pointer type 'void *' to Objective-C pointer type 'NSObject * requires a bridged cast NSAutoreleasePool* myPool = [[NSAutoreleasePool alloc] init]; Error: 'NSAutoreleasePool' is unavailable: not available in automatic reference counting mode

How to test EDGE or GPRS or any other slow/bad network

◇◆丶佛笑我妖孽 提交于 2019-12-10 10:43:04
问题 In my iOS app, I support to work online as well as offline. For this I have used Apple's Reachability code. Now I want to show user is offline if the cellular mobile network is EDGE or GPRS or bad/slow network. I have used the below code( Found solution ). Code: CTTelephonyNetworkInfo *telephonyInfo = [CTTelephonyNetworkInfo new]; NSLog(@"Current Radio Access Technology: %@", telephonyInfo.currentRadioAccessTechnology); [NSNotificationCenter.defaultCenter addObserverForName

Reachability vs UIDevice-Reachability

旧巷老猫 提交于 2019-12-10 10:21:29
问题 I need to test network reachability in my iPhone project. Which project is better to use? Reachability vs UIDevice-Reachability 回答1: Reachability if your only issue is to test network reachability. It's apple sample code and it's pretty easy to use. UIDevice is great for learning but a bit overkill just for network reachability. So in the end either of them will do. Depends on what you want to do. 来源: https://stackoverflow.com/questions/4954904/reachability-vs-uidevice-reachability

kReachabilityChangedNotification is called multiple times

旧时模样 提交于 2019-12-10 03:14:15
问题 I'm using the Reachability classes for checking when I got an internet connection en when it goes down. This is my code: IN VIEW DID LOAD: internetReachable = [Reachability reachabilityForInternetConnection]; [internetReachable startNotifier]; // check if a pathway to a random host exists hostReachable = [Reachability reachabilityWithHostname:@"www.google.com"]; [hostReachable startNotifier]; Then the notification method -(void) checkNetworkStatus:(NSNotification *)notice { // called after

网络访问第三方类库ASIHTTPRequest的总结

…衆ロ難τιáo~ 提交于 2019-12-09 23:07:09
这个类库很久没有更新了,不过好多项目还是在用它,所以还是来了解一下吧。 这个第三方类库包含22个文件, 1个配置, ASIHTTPRequestConfig.h 1个请求代理,1个HTTP请求,1个FormData请求, ASIHTTPRequestDelegate.h ASIHTTPRequest.h ASIHTTPRequest.m ASIFormDataRequest.h ASIFormDataRequest.m 1个进度代理, ASIProgressDelegate.h 1个缓存代理,1个缓存 ASICacheDelegate.h ASIDownloadCache.h ASIDownloadCache.m 2个加压解压, ASIDataCompressor.h ASIDataCompressor.m ASIDataDecompressor.h ASIDataDecompressor.m 1个输入流, ASIInputStream.h ASIInputStream.m 1个网络队列, ASINetworkQueue.h ASINetworkQueue.m 1个认证对话框, ASIAuthenticationDialog.h ASIAuthenticationDialog.m 1个连接工具。 Reachability.h (在源码的 External/Reachability

Where should I perform a Reachability check?

霸气de小男生 提交于 2019-12-09 19:22:51
问题 I want to check for a valid network connection. I followed Apple's Reachability example and put my check in applicationDidFinishLaunching #pragma mark - #pragma mark Application lifecycle - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { if(getenv("NSZombieEnabled") || getenv("NSAutoreleaseFreedObjectCheckEnabled")) { NSLog(@"NSZombieEnabled/NSAutoreleaseFreedObjectCheckEnabled enabled!"); } // Override point for customization after

How to define a reachability timeout on ios

℡╲_俬逩灬. 提交于 2019-12-09 17:51:49
问题 I use the Reachability class to know if I have an internet connection available. The problem is when wifi is available but not internet, the - (NetworkStatus) currentReachabilityStatus method take too much time. my code: Reachability* reachability = [Reachability reachabilityWithHostName:@"www.apple.com"]; NetworkStatus remoteHostStatus = [reachability currentReachabilityStatus]; The application "freeze" temporarily on the second line. How to define the maximum time for this waiting ? 回答1: I