nsthread in iphone xcode

Posted by BibiBuBu on Stack Overflow See other posts from Stack Overflow or by BibiBuBu
Published on 2010-05-04T11:41:49Z Indexed on 2010/05/04 11:48 UTC
Read the original article Hit count: 650

Filed under:
|

Good Day!

i want to use nsthreads in a project of xcode that will call a function which is for the network access and will check that if the network is there or not, so i need to have a thread which will execute after lets say 1 minutes to check the connectivity. and will continue run unless the app is closed.

[NSThread detachNewThreadSelector:@selector(startTheBackgroundJob) toTarget:self withObject:nil];

startTheBackgroundJob

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];

it works only for the first time but not any other, i mean only 1 loop it makes

can somebody help me in this regard.

Thanks

© Stack Overflow or respective owner

Related posts about iphone

Related posts about nsthread