标签: reachability

主线程阻塞导致应用程序在iOS 8中崩溃

我的应用程序在启动时崩溃,因为"未能及时更新场景"

这是因为可达性不能按时返回这是堆栈跟踪

com.tjango.Plus3 failed to scene-update in time

Elapsed total CPU time (seconds): 2.590 (user 2.590, system 0.000), 12% CPU 
Elapsed application CPU time (seconds): 0.302, 1% CPU


Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0:
_semaphore_wait_trap + 8
__dispatch_semaphore_wait_slow + 252
_xpc_connection_send_message_with_reply_sync + 184
___SCNetworkReachabilityServer_targetStatus + 192
___SCNetworkReachabilityGetFlags + 440
_SCNetworkReachabilityGetFlags + 232
-[Reachability currentReachabilityStatus] Reachability.m:295

这只发生在iOS 8上.

它被卡住的功能是Apple的Reachability库:我无法弄清楚为什么这个功能会阻止它.

- (NetworkStatus)currentReachabilityStatus

{

    NSAssert(_reachabilityRef != NULL, @"currentNetworkStatus called with NULL SCNetworkReachabilityRef");

    NetworkStatus returnValue = NotReachable;

    SCNetworkReachabilityFlags flags;



    if (SCNetworkReachabilityGetFlags(_reachabilityRef, &flags)) …

iphone reachability ios ios8

1
推荐指数
1
解决办法
1400
查看次数

Swift 中如何知道实际的互联网是否可用?

我希望在我的 WiFi 路由器颜色从绿色变为红色时收到通知

我正在制作一个应用程序,它可以通过 Swift 的菜单栏告诉您是否在线或离线,该应用程序是开源的,可以在https://github.com/deadcoder0904/net-alert找到

我想知道当 Swift 中 WiFi 颜色发生变化时是否可以收到通知。

我无法不断地 ping 我的服务器来知道颜色发生了变化,因为这会浪费互联网资源。

那么在 Swift 中是否可以知道这一点呢?

notifications reachability ios swift

1
推荐指数
1
解决办法
1483
查看次数

可达性示例代码

我正在使用Apple网站的Reachability示例代码.我已将Reachability.h和Reachability.m文件添加到我的项目中,我还添加了SystemConfiguration.framework.将#import"Reachability.h"添加到我的视图控制器.m文件中,并在视图控制器.h文件中声明了可达性变量.在我开始使用Reachability实例之前,所有内容都会编译而没有错误.

我得到ReachableViaWiFiNetwork和ReachableViaCarrierDataNetwork未声明的错误.

为什么会这样?

reachability = [Reachability reachabilityForInternetConnection];
NetworkStatus internetStatus = [reachability currentReachabilityStatus];

if ((internetStatus != ReachableViaWiFiNetwork) && (internetStatus != ReachableViaCarrierDataNetwork))
{
}
Run Code Online (Sandbox Code Playgroud)

reachability ios

0
推荐指数
1
解决办法
6400
查看次数

iPhone上必须提供有关状态更改的网络可达性通知?

许多可达性测试代码似乎都包含"通知"概念,以便在网络重新启动时,用户可以收到通知.

  1. 我是否需要实施"通知"部分?是否可以在用户尝试需要网络连接且无法使用的情况下提醒用户?(连接回来时没有通知)

  2. 我看到示例代码处理纯网络可用性(如果设备连接到wifi,3g等)并且具有对特定ip的可达性.我的应用程序需要在适当时连接到特定的IP地址.在这种情况下,只需提示是否在适当的时间内无法访问该IP是否需要处理或需要处理更多内容?(例如,提示不同的消息以提醒用户打开网络并警告用户我的IP不是到达)

谢谢

iphone networking reachability ios

0
推荐指数
1
解决办法
9020
查看次数

在 iPhone 模拟器上测试互联网连接

在iPhone模拟器上,WiFi始终打开,我无法使用Reachability功能测试互联网连接。NSURLConnection例如,如果我使用并联系 Google,我会

objective-c nsurlconnection reachability ios ios-simulator

0
推荐指数
1
解决办法
7774
查看次数

RestKit可达性为null

我的代码中包含以下代码AppDelegate.m- NSLog始终是结果,(null)因此永远不会触发无法访问的条件.我想知道为什么会发生这种情况/我做错了什么.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [IKRestKitManager configureRestKit];

    self.window.rootViewController = self.tabBarController;

    [self.window makeKeyAndVisible];

    [self prepareForLogin];

    return YES;
}

#pragma mark - onstart

- (void)prepareForLogin {

    if ([[[RKClient sharedClient] reachabilityObserver] isReachabilityDetermined] && ![[RKClient sharedClient] isNetworkReachable]) {
        UIAlertView *reachAV = [[UIAlertView alloc] initWithTitle:@"Cannot connect to Internet" message:@"iK9 cannot reach the Internet. Please be sure that your device is connected to the Internet and try again." delegate:self cancelButtonTitle:@"Retry" otherButtonTitles:nil];
        reachAV.tag = 0;
        [reachAV show];
    }

    NSLog(@"%@",[[[RKClient …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c reachability ios restkit

0
推荐指数
1
解决办法
2070
查看次数

将Reachability与ReactiveCocoa集成?

我正在使用ReactiveCocoa开发应用程序,现在是时候整合Reachability来处理网络事件了.

我不确定我所做的工作,因为一些RAC设计指南建议反对它.但是从我一直在研究的内容来看,我找不到合适的方法来管理这个(或者更可能的是,我不明白怎么做).

我们的想法是拥有一个独特的信号,在Reachability的通知上发送事件.我们的每个视图控制器都会订阅该信号,并以特定的方式对每个信号做出反应(即ale​​rtview,什么也不做,等等).

问题是我们只需要可见的viewcontroller来做出反应,所以我们使用的是RACDisposable.这样,当一个viewcontroller出现时,它会订阅信号,当它消失时,我们就会处理它.

根据RAC的设计指南,应避免使用RACDisposable,但我无法以任何其他方式处理此订阅/取消订阅周期.

这种方法对于这种"无限"信号是否正确?

我们的另一种选择是使用一个信号,当一个新的用户加入时,它会删除以前的用户.这样的事情存在吗?

提前感谢任何光线,你可以指出我的方向.


这个 SO帖子我开始尝试takeUntil:[self rac_willDeallocSignal]这在理论上似乎有用,但对我来说并不适用.由于此行为封装在Manager中,并且不应该取消分配,我不知道这对我有利.

我想到的一个选项是,takeUntil只要调用一个停止方法,就会触发一个新信号; 但它似乎只是因为我们不使用RACDisposable.

network-programming objective-c reachability ios reactive-cocoa

0
推荐指数
1
解决办法
874
查看次数

尝试使用Alamofire检查iOS设备上的互联网连接

我使用以下代码来检查互联网连接:

class Reachability {

    let networkReachabilityManager = Alamofire.NetworkReachabilityManager(host: "www.google.com")

    func checkForReachability() {
        self.networkReachabilityManager?.listener = { status in
            print("Network Status: \(status)")
            switch status {
            case .notReachable:
                print("no internet connection detected")
            //Show error here (no internet connection)
            case .reachable(_), .unknown:
                print("internet connection availible")
            }
        }
        self.networkReachabilityManager?.startListening()
    }
}
Run Code Online (Sandbox Code Playgroud)

当连接存在时,它成功调用.reachable中的块.但是如果连接缺席没有任何呼叫,为什么?

我这样称呼(保持对类的引用,所以它没有发布)

class AppDelegate: UIResponder, UIApplicationDelegate {
    var window: UIWindow?
    let reachabilityManager = Reachability()

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        window = UIWindow(frame: UIScreen.main.bounds)
        reachabilityManager.checkForReachability()
        return true
    }
Run Code Online (Sandbox Code Playgroud)

reachability ios swift alamofire

0
推荐指数
1
解决办法
1305
查看次数

检查 Internet 访问是否可用

在我的应用程序中,我只想在可以访问互联网的情况下拨打网络电话。

注意:我连接到没有互联网的 WiFi 点

我想测试互联网是否可用。我尝试使用这里描述的可达性,我也尝试了一个更简单的解决方案,如这里描述

问题在于 Reachability 会返回 Internet 可达的信息,而当它不可达时。另一种解决方案需要太多时间才能做出响应。我试图为请求和会话设置超时间隔,但它被忽略了。

如果我连接到没有互联网的 wifi,如何测试互联网可达性?

这是我使用的一些代码:

- (void) postAsyncTaskWithUrl:(NSString*)urlString
                      andType:(NSString*)requestType
                     andToken:(NSString*)token
          andPropertiesObject:(id)propObject
                   urlEncoded:(BOOL)isUrlEncoded
                  withSuccess:(nullable void(^)(id _Nullable))success
                   andFailure:(nullable void(^)(id _Nullable))failure
{

    internetReachableFoo = [Reachability reachabilityWithHostname:@"www.google.com"];

    __weak typeof(self) weakSelf = self;
    // Internet is reachable
    internetReachableFoo.reachableBlock = ^(Reachability*reach)
    {
                 NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:urlSt];
        [request setTimeoutInterval:20]; //Ignored ... WHY?

        NSURLSessionConfiguration *sessionConfigurations = [NSURLSessionConfiguration defaultSessionConfiguration];
        [sessionConfigurations setTimeoutIntervalForRequest:20]; //Ignored ... WHY?
        [sessionConfigurations setTimeoutIntervalForResource:20]; //Ignored ... WHY?
//        NSURLSession *session = [NSURLSession sharedSession]; …
Run Code Online (Sandbox Code Playgroud)

nsurlrequest reachability ios nsurlsession nsurlsessionconfiguration

0
推荐指数
1
解决办法
394
查看次数

iOS中的可达性类ARC错误

你好.我导入了reachability.h文件和reachability.m文件,以检查我的应用程序中的Internet连接,但是我收到了ARC错误.

我必须尝试将应用程序转换为ARC,但它仍然显示相同的错误如下:

compile Reachability.m and compile Reachability m files

implicit conversion of objective c pointer type 'Reachability *' to Cpointer type void * requires a bridged  cast

   ARC forbids explicit message send of 'dealloc'
   ARC forbids explicit message send of 'autorelease'
   ARC forbids explicit message send of 'autorelease'

  'NSAutoreleasePool' is unavailable: not available in automatic reference counting mode
  'NSAutoreleasePool' is unavailable: not available in automatic reference counting mode
   Cast of C pointer type 'void*' to Objective - C pointer type …
Run Code Online (Sandbox Code Playgroud)

objective-c reachability ios automatic-ref-counting

-1
推荐指数
1
解决办法
1571
查看次数

显示没有像Instagram那样的Internet连接消息

我想知道如何展示"没有互联网连接"就像Instagram一样,

举个例子 :

在此输入图像描述

这个透明的自定义消息动画显示在navigationController.真的很想把这个带到我的项目中,谢谢你的帮助

networking uitableview reachability ios swift

-1
推荐指数
1
解决办法
1090
查看次数