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?
You can stop the runloop by Core Fundation API :
CFRunLoopStop(CFRunLoopGetCurrent());