ChenYilong / ChenYilong/iOSInterviewQuestions
关于第 34 题关于 NSOperation 中需要手动添加 Autorelease Pool 的部分的疑问
Open
- Dominant language
- Swift
- Stars
- 9.5k
- Forks
- 2.8k
- PR merge metrics
- No merged PRs in 30d
Description
SO 上的这个答案 https://stackoverflow.com/questions/24562043/is-autoreleasepool-still-required-for-modern-ios-8-nsoperation-usage 提到,系统会自动设置好 Autorelease Pool。
这个答案 https://stackoverflow.com/questions/184409/nsautoreleasepool-in-nsoperation-main 提到说需要手动加入 Autorelease Pool,但是答案本身是 08 年的,所引用的苹果官方文档应该也已经更新了(搜不到对应的内容)。
按照我自己的理解,应该是不需要的,因为 NSOperation 所跑的线程也是 Cocoa 创建的线程,Cocoa 创建的线程中应该就已经设置好 Autorelease Pool 了。
按照文档的说法,Operation 里的 Pool 不一定什么时候会进行 drain,所以添加自己的 Pool 会更利于管理。
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.