Using NSOperationQueue to perform iOS application initialization

295 Views Asked by At

Is it OK to use NSOperationQueue addOperationWithBlock to delay initialization code, so the app was not killed by an iOS watchdog?

As we know iOS kills the app if it spends too much time in application: didFinishLaunchingWithOptions or in applicationDidBecomeActive.

But I have a lot of things to do for initialization. Currently I am doing a bunch of synchronious HTTP requests (let it be synchronious :) ) whcih can take unpredicatble duration of time.

Could you suggest a nicer solution to this problem?

Thank you!

EDIT: Everyone, synced HTTP requests are not a subject of the question. I have a lot of third-party SDKs integrated. I have to initialize all of them but I have no idea what they are doing during initialization. I am just trying to minimize the risk of being killed by iOS.

1

There are 1 best solutions below

0
On BEST ANSWER

Perform your web requests asynchronously and if necessary show a loading UI while they progress. You should never run synchronous web requests in application:didFinishLaunchingWithOptions:, watchdog is there for a reason.