Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>how can I distinguish in the NSURLConnection delegate (connectionDidFinishLoading) which URL call is being made?</p> </blockquote> <p>Each of the delegate methods (such as <code>-connectionDidFinishLoading:</code>) has a <code>connection</code> parameter that tells you which connection sent the message. A given connection can only load one URL at a time, so there's a one to one correspondence between URLs and connections.</p> <blockquote> <p>How can I tell outside of "connectionDidFinishLoading" when the download is completed?</p> </blockquote> <p>That method <em>tells</em> you when the connection is finished. It's up to you to store that information somewhere where it's useful to your app.</p> <p><strong>Update:</strong> Based on what you've added, your "processing" class is your app's model. The rest of the app shouldn't care that each transaction involves a message to the server -- that's the model's business alone. Also, there's no reason that the model has to be a single object (let alone a singleton) -- it can be a group of objects that work together.</p> <p>So, you might have a class (let's call it Processor) that represents the application's interface to the model (some might even call this a "model controller"). An instance of Processor might create a local database for storing the current local state of the app.You might also have a Transaction class that represents a single transaction with the server. A transaction could create a request, send it to the server, get the response, update the database, and tell the Processor that the transaction is done. Or, maybe when some other part of the app (like one of your view controllers) asks the Processor to process a new transaction, the Processor passes the requesting object along to the transaction that it creates so that the transaction can update the requestor directly.</p> <p>It's hard to say what the best plan for your app is without knowing where you're planning on taking it, but the usual guidelines hold:</p> <ul> <li><p>break your problem into parts that are easier to solve</p></li> <li><p>limit the scope of each class's responsibilities</p></li> <li><p>if something seems to complicated, it probably is</p></li> </ul> <p>Breaking your model up into several classes will make it easier to test, as well. You can imagine how easy it would be to write a set of unit tests for the Transaction class. The same goes for Processor -- if the server transaction stuff is in a different class, it's easier to test that the Processor is doing the right thing.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. COCaleb - I know the connectionDidFinishLoading is only executed when it has finished loading... My question relates to being able to know outside of it. For example, start a spinner upon making the call and knowing when it's done as to stop the spinner outside of the delegate.
      singulars
    2. CO@sangony Right, but the solution depends on your code. How are you keeping track of the various connections? What in your app depends on the state of the connections? Who's responsible for those things -- the connection delegate or some other object? Your connection delegate's implementation of the `didFinish` method could post a notification, or it could update an entry in a dictionary, or it could stop the spinner itself, or something else. The fact that each application will need to do something different is the reason that there's a `didFinish` delegate method in the first place.
      singulars
    3. CORight now I am trying to write generic code to get around that part but I am thinking about using a class variable (sorry if I am using the wrong term here) to keep track of who is making the call. Example, set classVar to 1 if button one is pressed to update data in table 1, set classVar to 2 if... In the didFinish I thought about using the classVar to see who is running. But being a newbie this looks somewhat wrong to me. I also thought about setting variables/dictionaries from didFinish... but how do I check for that on the outside? I thought about timers but that also seems wrong.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload