I want to schedule a thread after a thread completion.
Is it possible ? How?
For example ( to specify my need )
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
// 1. response - schedule myThread
// 2. response - schedule a new thread which will be executed after myThread
// 3. response - schedule a new thread which will be executed after second thread
// .....
}
If you use NSOperations you can use the addDependency: method to specify an operation’s dependencies.
NSInvocationOperation will probably be useful to you if you go this route.
Edit: I just re-read the subject and you’re on iPhone so you don’t have blocks, but for reference, if you have blocks available, NSBlockOperation is even better.
Note that when using these methods to perform asynchronous operations (and assuming the code in them uses autorelease) you’ll be responsible for instantiating an
NSAutoreleasePoolwhen your method starts running and releasing/draining it upon exit.