@autoreleasepool is a new feature of Objective-C 3.0. An example of its usage and the equivalent in previous versions of Objective-C:
- @autoreleasepool {
- // Do some cool stuff
- }
- NSAutoreleasePool *pool = [NSAutoreleasePool new];
- // Do some cool stuff
- [pool drain];
Note that the second sample is no longer valid code -- instantiating your own autorelease pool objects is no longer allowed.
The primary reason for this syntactical change is to allow for moving autorelease pools down the stack into the runtime along with retain/release itself -- in previous versions of ObjC/Cocoa, the autorelease functionality was provided by Foundation. L'implementazione di ARC è resa più facile da questo cambiamento e sembra fornire anche un aumento delle prestazioni.
Per maggiori informazioni vedi la sessione "Objective-C Advancements In-Depth" dal WWDC2011, disponibile qui per chiunque abbia un account ADC gratuito: https://developer.apple.com/videos/wwdc/2011/includes/objective-c-advancements-in-depth.html#objective-c-advancements-in-depth