LispWorks Objective-C and Cocoa Interface User Guide and Reference Manual > 2 Objective-C Reference

NextPrevUpTopContentsIndex

with-autorelease-pool

Macro
Summary

Evaluates forms in the scope of a temporary autorelease pool.

Package

objc

Signature

with-autorelease-pool ( option *) form * => values

Arguments

option

There are currently no options.

form

A form.

Values

values

The values returned by the last form .

Description

The macro with-auto-release-pool creates a new autorelease pool and evaluates each form in sequence. The pool is released at the end, even if a non-local exit is performed by the form s. An autorelease pool is provided automatically for the main thread when running CAPI with Cocoa, but other threads need to allocate one if they call Objective-C methods that use autorelease.

Example

The "description" method returns an autoreleased NSString, so to make this function safe for use anywhere, the with-auto-release-pool macro is used:

(defun object-description (object)
  (with-autorelease-pool ()
    (invoke-into 'string object "description")))
See also

autorelease
make-autorelease-pool

 


LispWorks Objective-C and Cocoa Interface User Guide and Reference Manual - 22 Dec 2009

NextPrevUpTopContentsIndex