This is part of “Make my first iPhone app in 16 weeks” series.
When to avoid:
- Networking (use asynchronous API’s instead)
- initWithContentsofURL needs to be used with asynchronous API’s. Otherwise, it will block the main thread.
- Reachability (use asynchronous API’s instead)
- Idle Behavior (use NSTimer instead)
Best concurrency architecture
- Thread confinement – one object on one thread (NSOperation provides this functionality)
- Encapsulates code & data
- Can query for the state of execution (isExecuting, isFinished, and isCancelled)
- Can set dependencies (let a particular operation be dependent upon another operation) – very useful!
- Can set priority
Regulates a set of NSOperation objects
- Can suspend and resume
- Can up-throttle or down-throttle the queue