I got this problem with NSURLConnection instances, that after using an arbitrary number of them, they stop working and never call their delegate
's methods. The way they are put to work is the following:
[[NSRunLoop mainRunLoop] addPort:self.port forMode:NSDefaultRunLoopMode];
[_connection scheduleInRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode];
[self.connection start];
[[NSRunLoop mainRunLoop] run];
The fact that they stop working after using a number of them, makes me think that they run out of any of the resources (perhaps ports on the main runLoop or something else).
It seems like everything is getting cleaned up pretty well
[_connection cancel];
[_connection release];
[[NSRunLoop mainRunLoop] removePort:self.port forMode:NSDefaultRunLoopMode];
[_port release];
[super dealloc];
Do you guys see anything wrong with this approach? Any ideas why they might stop working?