To check for internet connection you can use this:
- (BOOL)connected {
Reachability *reachability = [Reachability reachabilityForInternetConnection];
NetworkStatus networkStatus = [reachability currentReachabilityStatus];
return !(networkStatus == NotReachable);
}
This returns a BOOL which you can use in a conditional to check for an internet connection.
NOTE: Be Sure to add the the proper frameworks and add the following at the top of your .m file:
#import "Reachability.h"
#import <SystemConfiguration/SystemConfiguration.h>
UPDATE #1:
Based on your comment it seems that you want to test for connectivity via a timer. The following code will check for internet every second. This is not recommended but this should accomplish what you are asking:
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:(1.0/60.0)
target:self
selector:@selector(checkInterWeb)
userInfo:nil
repeats:YES];
Also you should create an ivar to the timer so you can invalidate it when you no longer need it like so:
if(timer) {
[timer invalidate];
timer = nil;
}