开发者

NSBlockOperation and NSAutoreleasePool

开发者 https://www.devze.com 2023-02-13 09:52 出处:网络
Normally when you create an NSOperation su开发者_开发百科bclass you are responsible for creating and releasing an NSAutoreleasePool in the -main method.

Normally when you create an NSOperation su开发者_开发百科bclass you are responsible for creating and releasing an NSAutoreleasePool in the -main method.

When you use an NSBlockOperation, do you need to create an autorelease pool in the block?


No. GCD (which NSOperationQueue is built on top of as of OS X 10.6 or iOS 4.2) manages autorelease pools for you, the same way that NSRunLoop does.


I don’t think so, as the work queues have their own pools already created for you.


Adam,

Your best bet is to read up on block memory behavior with objects. Here is the link for the iOS Blocks and Variables the bottom of this page has information regarding object types.

Frank

0

精彩评论

暂无评论...
验证码 换一张
取 消