Hi I have an web service based app that will interchange data with our server. Since I have a dedicated class doing my work, the main view controller will actually call the worker every time. The worker itself knows when the connection finished since it is a NSURLConnectionDelegate. However I need to inform the main view controller whenever the work is done. The worker is a delegate of main view controller so it knows when it need to start working. Please help me.
Share
You should do the other way around.
First declare your worker object as a member of your main view controller(and of course, make it a property), then from you main view controller, you can just call
[self.worker sendRequstToServer]to send the request.Second, within your main view controller, wherever you initialize your work object, don’t forget to put
self = worker.delegate.Third, declare a delegate method in your worker class, something like
-(void)webServiceCallFinished(), and call[self.delegate webServiceCallFinished]in your worker’s-connectionDidFinishLoading()(you might wanna do in-parserDidEndDocument()if you are using NSXMLParer to parse xml)Last, you wanna declare your main view controller as the delegate of your worker class and implement
-webServiceCallFinished().Hope this helps.