I have a TableView that recieves data from a server with a method call retrieveData
.
I use the Reachability to test if the user has internet connection.
If YES the retrieveData
is called.
If NOT i get a NSLog printed.
All works fine, BUT.. Even if it has connection, the table takes a few second to load and that's not what I want. How can I be immediately?
I check the connection in the viewDidLoad method.
- (void)viewDidLoad
{
[super viewDidLoad];
Reachability* reach = [Reachability reachabilityWithHostname:@"www.google.com"];
reach.reachableBlock = ^(Reachability*reach)
{
// Load the Table Content
[self retrieveData];
};
reach.unreachableBlock = ^(Reachability*reach)
{
NSLog(@"no internet");
};
[reach startNotifier];
}
Reachability
returns immediately. Probe in your code where it takes the time. – Ayan Sengupta