Where should I do the availability check?

I want to check the correct network connection. I followed the example of Apple Reachability and put my check inapplicationDidFinishLaunching

#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 application launch.
        [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(reachabilityChanged:) name: kReachabilityChangedNotification object: nil];

        //Check for connectivity
        internetReach = [[Reachability reachabilityForInternetConnection] retain];
        [internetReach startNotifer];
        [self updateInterfaceWithReachability: internetReach];

        [window addSubview:navigationController.view];
        [window makeKeyAndVisible];

        return YES;
    }

However, my application will sometimes crash with an error Application Failed to Launch in Time

I sent my crash as an SO question here: Application failed to start on time

I'm not sure where I should perform the availability check?

+3
source share
2 answers

In -applicationDidBecomeActiveyou can call a method in the background that uses reachability code with -performSelectorInBackground:withObject:.

0
source

(30 ) . ( 30), , .

Reachability , , , , , .

+3

Source: https://habr.com/ru/post/1769979/


All Articles