On this page:
5.12.1 Strings
_  NSString
5.12.2 Allocation Pools
call-with-autorelease
with-autorelease

5.12 Cocoa Foundation

The ffi/unsafe/nsalloc and ffi/unsafe/nsstring libraries provide basic facilities for working with Cocoa and/or Mac OS Foundation libraries (usually along with ffi/objc).

5.12.1 Strings

 (require ffi/unsafe/nsstring) package: base

value

_NSString : ctype?

A type that converts between Racket strings and NSString* (a.k.a. CFStringRef) values. That is, use _NSString as a type for a foreign-function NSString* argument or result.

The _NSString conversion keeps a weak mapping from Racket strings to converted strings, so that converting the same string (in the equal? sense) multiple times may avoid allocating multiple NSString objects.

5.12.2 Allocation Pools

 (require ffi/unsafe/nsalloc) package: base
Calling any Foundation API that allocates requires an NSAutoreleasePool installed. The ffi/unsafe/nsalloc library provides a function and shorthand syntactic form for setting up such a context. (The _NSString type creates an autorelease pool implicitly while converting from/to a Racket string, however.)

procedure

(call-with-autorelease thunk)  any

  thunk : (-> any)
Calls thunk in atomic mode and with a fresh NSAutoreleasePool that is released after thunk returns.

syntax

(with-autorelease expr)

A shorthand for (call-with-autorelease (lambda () expr)).