再会!
我想在一个 xcode 项目中使用 nsthreads,它将调用一个用于网络访问的函数,并检查网络是否存在,所以我需要一个线程,它会在让我们说 1 分钟后执行检查连通性。除非应用程序关闭,否则将继续运行。
[NSThread detachNewThreadSelector:@selector(startTheBackgroundJob) toTarget:self withObject:nil];
开始后台工作
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// wait for 3 seconds before starting the thread, you don't have to do that. This is just an example how to stop the NSThread for some time
[NSThread sleepForTimeInterval:5];
//[self performSelectorInBackground:@selector(checkNet) withObject:nil];
[self performSelectorOnMainThread:@selector(checkNet) withObject:nil waitUntilDone:YES];
[pool release];
它仅在第一次时有效,但在其他任何时候都无效,我的意思是它只产生 1 个循环
有人可以在这方面帮助我。
谢谢