Reputation: 5823
I need to upload some left-over data to server in application:didFinishLaunchingWithOptions
, but it takes some time and eventually the app may be killed as it cannot finish launching in time, so I used:
[myObject performSelector:withObject:afterDelay:]
with 0.2f delay, to let application:didFinishLaunchingWithOptions
finish, but it does not look like a good idea, so I wonder is there a way I can perform the selector just after application:didFinishLaunchingWithOptions
?
I know there are applicationDidBecomeActive
but I need it to be executed in application:didFinishLaunchingWithOptions
.
Upvotes: 1
Views: 381
Reputation: 185871
If you use a delay of 0, it will be executed as soon as control returns to the runloop.
However, if this is blocking for too long in appDidFinishLaunching, then it will also block no matter when you run it. You really should move this code to a background thread. Synchronous network access on the main thread is never a good idea.
Upvotes: 3