Autorelease pools in appkit applications

2019-04-17 08:07发布

I'm having difficulties to understand exactly WHEN autorelease pools are created and released in AppKit apps.

For example, if I have an ApplicationController class that overrides init, is there an autorelease pool that gets created before it starts and gets drained after it ends?

1条回答
闹够了就滚
2楼-- · 2019-04-17 08:19

The main thread in an AppKit application runs an NSRunLoop to process events. NSRunLoop creates a new autorelease pool every time it processes a new event (or timer) and drains it once control flow has returned to the NSRunLoop. So in essence, every pass through the run loop has a fresh autorelease pool.

查看更多
登录 后发表回答