top | item 29312321

(no title)

ash_gti | 4 years ago

If the object is not autoreleased then doing a release call will deallocate the object, otherwise it will be added to the nearest autorelease pool from the current stack and be deallocated when the pool is drained.

Swift and obj-c have the same ARC semantics, so I'm not sure what you mean by swift-style refcounting. It should be identical to the obj-c ARC semantics.

https://clang.llvm.org/docs/AutomaticReferenceCounting.html outlines the ARC semantics, including the autorelease behavior.

discuss

order

raphlinus|4 years ago

By "swift-style refcounting" I mean the object is reliably deallocated exactly when the last release is called. Following up on the response to comex, I would say I would get these semantics if I called objc_retainAutoreleasedReturnValue on the allocating method's return value, and it actually worked.