In a reference-counted environment, releases and pops the receiver; in a garbage-collected environment, triggers garbage collection if the memory allocated since the last collection is greater than the current threshold.
- iOS 2.0+
- macOS 10.4+
- UIKit for Mac 13.0+Beta
- tvOS 9.0+
- watchOS 2.0+
In a reference-counted environment, this method behaves the same as
release. Since an autorelease pool cannot be retained (see
retain), this therefore causes the receiver to be deallocated. When an autorelease pool is deallocated, it sends a
release message to all its autoreleased objects. If an object is added several times to the same pool, when the pool is deallocated it receives a
release message for each time it was added.
In a garbage-collected environment,
release is a no-op, so unless you do not want to give the collector a hint it is important to use
drain in any code that may be compiled for a garbage-collected environment.