Please look at this code:
@interface myObject:NSObject
-(void)function:(id)param;
@end
@implementation myObject
-(void)function:(id)param
{
NSLog(@"BEFORE");
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:20]];
NSLog(@"AFTER");
}
@end
int main(int argc, char *argv[])
{
myObject *object = [[myObject alloc] init];
[NSThread detachNewThreadSelector:@selector(function:) toTarget:object withObject:nil];
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
The function
method is called but there's no 20 seconds pause. What should i do to make NSRunLoop
work in a detached thread?