Consider this example:
- (void)doSomething {
@autoreleasepool {
if (someCondition) {
/* ... allocate some autoreleased objects here ... */
return;
}
}
}
Previously, with manual NSAutoreleasePools, if we returned early, we needed to call [pool drain]
, otherwise the pool would not be drained.
With the new @autoreleasepool {}