Application Lifecycle & autorelease pools

来源:互联网 时间:1970-01-01

Application Lifecycle

After application:didFinishLaunchingWithOptions:, then what?

Application enters a “run loop” repeatedly doing the following ...

An autorelease pool is created (more on this in a moment)Application waits for events (touch, timed event, I/O, etc.)
Events are dispatched through UIKit objects and often on to your objects (via delegates, etc.)
When all is done, the screen is updated (appropriate drawRect: methods are called)
The autorelease pool is drained

Rinse, repeat. 



注:两次autorelease 对象会导致自动释放池最终两次release 该对象,可能会使程序crash。