There is two subtopic for this issue: first is job could be executed while the application is in a running mode or job could be executed when the application is suspended. Both two scenarios are possible in iPhone, however the later is really restricted.
If you want to run a job during the suspended phase, where the application is closed and stays in the background, there are a few operations that iPhone allows developer to do. These operations could be a VOIP (like skype does), audi (like iPod does) or a location tracking. Other than these there is no operation that developers can do in iPhone. Also note that mimicking your application as if it is using VOIP would cause your application to be rejected from app store, so don't even try to get around things!.
Another issue is to run job in the background while the application is running. This is done through threading in the iPhone. NSThread is the Objective-C class for this. Go exploit it!. But careful about memory management. Here is a few tips:
- Allocate and deallocate your auto release pool. Otherwise you'll end up with memory leaks.
- Don't play with UIKit unless you are in a main thread. This will cause some undefined behavior.
Addition to the last scenario might be the possibility of running the job periodically. This can be done by firing and NSTimer and adding this to the current running loop.
No comments:
Post a Comment