You are talking about "synchronous" and "asynchronous" operations. Synchronous operations are those that occur in step with your call code. Most of Cocoa works this way: you send a message to an object, say, to format a string, etc., and by the time the line of code is completed, the operation is complete.
But in the real world, some operations take longer than “instantaneous” ones (some intense graphics work, but mostly high or variable delays, such as disk I / O or, worse, network connectivity). These operations are unpredictable, and if the code is blocked until completion, it can be blocked indefinitely or forever, and that is not good.
So, how do we deal with this, we need to configure “callbacks” - you say: “Leave and perform this operation, and when you are done, call this other function.” Then inside this “callback” function, you start the second operation, which depends on the first. This way you don't spin in circles, waiting, you just get called “asynchronously” when each task is completed.
NSURLConnection (like other high latency objects) allows you to follow this pattern. When you create a connection, you configure delegate , and the delegate is called by certain methods when the resulting data is available. That way, you can serialize your operations if the delegate method starts the second operation only after the first is complete.
source share