I need a simple pinger on the iPhone. So I try to get the SimplePing example running on iPhone. But when i init the pinger like in the example, the main runloop does not handle the events generated by SimplePing. Here is the initcode:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
_pinger = [SimplePing simplePingWithHostName:@"192.168.210.1"];
_pinger.delegate = self;
[_pinger start];
NSLog(@"Pinger started");
[self.window makeKeyAndVisible];
return YES; }
If I trigger the runloop directly in this function with somthing like that:
do {
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
} while (_pinger != nil);
it works. So my question is, why are the events not processed in the main run loop of UIApplicationMain
, and what do I have to do to get this done by the main runloop?