Although the use of the NSAID utoreleasepool has changed a lot after the introduction of arc, it is necessary to understand the mechanism of the NSAID eleasepool:
NSAID utoreleasepool * Pool = [NSAID utoreleasepool alloc] init];
// Do something
After,
The difference between [pool drain] and [pool release:
ReleaseIn the reference counting environment, because the NSAID pool is a type that cannot be retain, the release will directly dealloc pool object. When the pool is dealloc, the pool sends a release message to all objects in the pool. If an object is autorelisted multiple times in the pool, each autorelease release of this object by the pool will be release. In the GC environment, release is a no-op operation (indicating that no operation is performed. It is a computer command that occupies a small amount of space but points out that no operation is performed ).
DrainIn the reference counting environment, it performs the same behavior as release. In the GC environment, this method calls objc_collect_if_needed to start GC.
Therefore, the focus is: In the GC environment, release is a no-op, so unless you do not want to start GC in the GC environment, you should use drain instead of using release to release the pool.