I have a parser class and a view controller class. In the parser class i am sending a request and receiving an asynchronous response. I want to download the same several times but while sending different parameters each time. I have registered an observer in the class:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dataDownloadComplete:) name:OP_DataComplete object:nil];
and then post a notification in :
-(void)connectionDidFinishLoading:(NSURLConnection *)
connection method of the parser class.
[[NSNotificationCenter defaultCenter] postNotificationName:OP_DataComplete object:nil];
I ca开发者_Python百科n't enclose the observer inside a For loop. What better alternative is there? Please help. Thanks in advance.
You probably do not need a for loop at all. As you said you send a request asynchroniously, so just send it in your observer code instead of making a for loop. Then you get back to your observer after response is downloaded.
精彩评论