Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop an NSRunLoop

I have a connection in a thread, so I add it to the run loop to get all data:

  [[NSRunLoop currentRunLoop] run];
  [connection scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];

But I can't find any way to stop it

- (void)connectionDidFinishLoading:(NSURLConnection *)connection{
    if([NSRunLoop currentRunLoop]){
        [[NSRunLoop currentRunLoop] cancelPerformSelectorsWithTarget:self];
    }
    [connection cancel];
}

How can I stop this loop?

like image 456
Makio Avatar asked Apr 25 '13 10:04

Makio


1 Answers

You can stop the runloop by Core Fundation API :

CFRunLoopStop(CFRunLoopGetCurrent());
like image 78
hrchen Avatar answered Oct 16 '22 09:10

hrchen