@autoreleasepool 代替 NSAutoreleasepool
新的xcode的holle world开始给人的印象就是简洁了,可是到底哪里发生了变化呢?原来是原先的NSAutoreleasepool被@autoreleasepool所替代。一下来自苹果官方手册,我做了一下翻译。
NSAutoreleasePool 类 参考手册
继承自
NSObject
Conforms to
NSObject (NSObject)
Framework
/System/Library/Frameworks/Foundation.framework
Availability
Available in Mac OS X v10.0 and later.
相关教程
Advanced Memory Management Programming Guide
声明
NSAutoreleasePool.h
Related sample code
CocoaSpeechSynthesisExample
OpenCL NBody Simulation Example
SpellingChecker CarbonCocoa Bundled
SpellingChecker-CarbonCocoa
SpellingChecker-CocoaCarbon
概览
The NSAutoreleasePool class is used to support Cocoa’s reference-counted memory management system. An autorelease pool stores objects that are sent a release message when the pool itself is drained.
Important: If you use Automatic Reference Counting (ARC), you cannot use autorelease pools directly. Instead, you use @autoreleasepool blocks instead. For example, in place of:
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init;
// Code benefitting from a local autorelease pool.
[pool release];
you would write:
@autoreleasepool {
// Code benefitting from a local autorelease pool.
}
@autoreleasepool blocks are more efficient than using an instance of NSAutoreleasePool directly; you can also use them even if you do not use ARC
新的xcode的holle world开始给人的印象就是简洁了,可是到底哪里发生了变化呢?原来是原先的NSAutoreleasepool被@autoreleasepool所替代。一下来自苹果官方手册,我做了一下翻译。
NSAutoreleasePool 类 参考手册
继承自
NSObject
Conforms to
NSObject (NSObject)
Framework
/System/Library/Frameworks/Foundation.framework
Availability
Available in Mac OS X v10.0 and later.
相关教程
Advanced Memory Management Programming Guide
声明
NSAutoreleasePool.h
Related sample code
CocoaSpeechSynthesisExample
OpenCL NBody Simulation Example
SpellingChecker CarbonCocoa Bundled
SpellingChecker-CarbonCocoa
SpellingChecker-CocoaCarbon
概览
The NSAutoreleasePool class is used to support Cocoa’s reference-counted memory management system. An autorelease pool stores objects that are sent a release message when the pool itself is drained.
Important: If you use Automatic Reference Counting (ARC), you cannot use autorelease pools directly. Instead, you use @autoreleasepool blocks instead. For example, in place of:
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init;
// Code benefitting from a local autorelease pool.
[pool release];
you would write:
@autoreleasepool {
// Code benefitting from a local autorelease pool.
}
@autoreleasepool blocks are more efficient than using an instance of NSAutoreleasePool directly; you can also use them even if you do not use ARC
本文介绍了Xcode中@autoreleasepool的使用方式及其相对于NSAutoreleasePool的优势。在使用自动引用计数(ARC)的情况下,推荐使用@autoreleasepool块来提高效率。
3776

被折叠的 条评论
为什么被折叠?



