I’m writing my own delegate protocol and class to handle some background processing, and I’m trying to understand the standard way of passing data back and forth. I have a class set up to do the background work, and a protocol with a success and error method.
My question (that hopefully isn’t too vague) is: what is the standard way of handling the request, response, and error. Should the object itself contain the request, response, and error, so that the object can be the single parameter to the delegate methods? Or should the delegate methods include the response or error as additional parameters (in which case, how should memory management work)? In general, what is the best practice for passing data back and forth to delegates?
I’d recommend that your delegate protocol allows for request, response, and error. For example, the NSURLConnection delegate has methods like these: