iOS ์ฑ์ ์๋ช ์ฃผ๊ธฐ(Life Cycle)

- Not Running: ์์ ์ฑ์ด ์คํ๋๊ณ ์์ง ์์ ์ํ
- Foreground: ์ฑ์ด ํ๋ฉด์ ์ ์ ํ๊ณ ์์, InActive๊ฐ Active๋ฅผ ๊ฐ์ธ๊ณ ์์(Active ์ํ๋ก ๋ค์ด๊ฐ๊ณ Active ์ํ์์ ๋์ค๋ ค๋ฉด InActive ์ํ๋ฅผ ๊ฑฐ์ณ์ผํจ - ์ผ์ข
์ ๊ด๋ฌธ)
- InActive: ์ฌ์ฉ์๊ฐ full control์ด ๋ถ๊ฐํ ์ํ(OS๊ฐ ๋ง๋ค์ด์ค), ์ธ๋ถ์ ์ธ ์์ธ(Interrupt)์ ์ํด ์ด ์ํ๊ฐ ๋ ์ ์์
- Active: ์ค์ง์ ์ผ๋ก ํ๋ํ๊ณ ์๋ ์ํ
- Background: ์ฑ์ด ํ๋ฉด์ ์ ์ ํ๊ณ ์์ง ์์ (ํ๋ฉด์์๋ ๋ด๋ ค๊ฐ์ง๋ง ๋ฉ๋ชจ๋ฆฌ์๋ ์ฌ๋ผ๊ฐ์์)
- Suspend: ๋ณดํต์ ๊ฒฝ์ฐ, ๊ฐ๋งํ ๊ธฐ๋ค๋ฆฌ๋ ์ํ
- ๋ฉ๋ชจ๋ฆฌ ๊ณต๊ฐ์ด ๋ถ์กฑํด์ง๋ฉด Not Running ์ํ๋ก ๊ฐ(OS๊ฐ ๊ฒฐ์ )
- Running: ์ผ์ ๋ถ๋ถ, ์ ํ์ (Timeout)
- e.g. Email์ ๋ณด๋ด๊ณ ๋๊ฐ์ง๋ง ๊ณ์ ๋ณด๋ด๋ ์ค, ํ์ด๋จธ๋ฅผ ๋๋ ค๋๊ณ background๋ก ๋ณด๋ด๋ ๊ฒฝ์ฐ ๋ฑ
- Suspend: ๋ณดํต์ ๊ฒฝ์ฐ, ๊ฐ๋งํ ๊ธฐ๋ค๋ฆฌ๋ ์ํ
โ Foreground ์ Background์ ๊ณตํต์ : ์ฑ์ด ๋ฉ๋ชจ๋ฆฌ์ ์ฌ๋ผ๊ฐ ์์
App Delegate ๋ฉ์๋์ ๋งค์นญ ์์ผ๋ณธ๋ค๋ฉด?
- ์ฑ์ ์คํํ์ ๊ฒฝ์ฐ: application:DidFinishLaunchingWithOptions: , applicationDidBecomeActive
- ์ฑ์ด Active ์ํ์์ InActive ์ํ๋ก ๋ค์ด๊ฐ์ ๊ฒฝ์ฐ: ์ฑ์ด InActive ์ํ๋ก ์ ํ๋๊ธฐ ์ง์ ์ applicationWillResignActive ํธ์ถ
- ์ฑ์ด Background๋ก ๊ฐ๋ ๊ฒฝ์ฐ: ์ฑ์ด Background ์ํ๋ก ์ ํ๋ ์งํ applicationDidEnterBackground ํธ์ถ
- ๋ค์ Foreground๋ก ๊ฐ๋ ๊ฒฝ์ฐ: ์ฑ์ด Active ์ํ๋ก ์ ํ๋๊ธฐ ์ง์ (ํ๋ฉด์ ๋ณด์ฌ์ง๊ธฐ ์ง์ ์ ์์ )์ applicationWillEnterForeground ํธ์ถ
- ์ฑ์ด Background์์ Running์ ํ๋ค๊ฐ Timeout์ด ๋ฌ์ ๊ฒฝ์ฐ, Background์์ ๋ฉ๋ชจ๋ฆฌ ๋ถ์กฑํด์ ๋ด๋ ค๊ฐ ๊ฒฝ์ฐ: ์ฑ์ด ์ข ๋ฃ๋๊ธฐ ์ง์ ์ applicationWillTerminate ํธ์ถ
Reference: https://www.youtube.com/watch?v=7GlwS2lOKbE