OK to assign one NSObject as the delegate of multiple ASIHTTPRequests?
Is it OK to assign one NSObject
as the delegate of multiple, asynchronous ASIHTTPRequest
s?
My concern is that two or more requests will call the same callback method on the delegate at the same time.
I checked that ASIHTTPRequest
calls the delegate callbacks on the main thread, just as NSURLConnection
do开发者_如何学JAVAes. So, it's OK, right?
Yes, this is fine, normal, and part of the design of delegates.
Yes, this is a perfectly normal thing to do. Properly designed APIs should pass the calling object as a parameter of any delegate methods. This way, an object acting as a delegate can (if necessary) distinguish its delegate responsibilities by delegating object instance.
精彩评论