Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can I run a while(true) in applicationWillTerminate?

Tags:

ios

swift

iphone

why can i run a while(true) in the applicationWillTerminate Method in the AppDelegate and it doesn't stop after five seconds?

I printed a log to the console and the loop is still running after a minute..

In Apples Documentation it sounds like after five seconds the Process is killed. Btw my phone was broken after this, i needed to do a hard reset.

Thanks, im just curious

like image 824
Jonathan K Avatar asked Feb 06 '18 14:02

Jonathan K


1 Answers

The documentation says:

If the method does not return before time expires the system may kill the process altogether

The documentation says that approximately 5 seconds is the guaranteed time in which your app won't get killed.

I am pretty sure the app will be terminated sooner or later because iOS have background processes that make sure of it.

Infinite loops without pauses eat up CPU and its very difficult for any operating system to recover from them.

like image 115
Sulthan Avatar answered Nov 08 '22 17:11

Sulthan