I have a nsurlconnection that i set the delegate as self. I have the four methods didrecieve, did finish, did fail, and the other one. My question is how to set it up so that i include what needs to be done after completion. This is needed because I have different nsurlconnection requests throughout the class, and have unique responses. Thanks.
-
Answered here: http://stackoverflow.com/questions/10357890/check-which-request-is-which-from-nsurlconnection-delegate/10358560#10358560 – danh Apr 29 '12 at 23:29
1 Answers
Your question is not clear. First of all, it doesn't sound like you're using NSURLConnection
synchronously, so your question title seems wrong. Then, if you want to do something when the connection completes, put it in the did-finish and did-fail methods.
If you want to distinguish among multiple connections, use the parameter for the connection that's passed in to the delegate methods. One thing you can do is have a dictionary whose keys are [NSValue valueWithNonretainedObject:theConnection]
. The value can be anything of use, including another dictionary.
Or, you can use a separate object to manage and be the delegate for each connection. If there's enough specific to each connection that you have to keep track of data about it, then maybe it warrants a separate object to manage things.

- 88,520
- 7
- 116
- 154
-
-
1You don't call the delegate method, nor do you pass anything into it. `NSURLConnection` calls the delegate methods on its delegate (which is your object) and passes itself as the first parameter. Your delegate can make decisions or look up other information based on that parameter. – Ken Thomases Apr 30 '12 at 05:53