From d450ff94cbabb1cb5fa9629538c473ced824edef Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Sun, 13 Jan 2013 15:30:38 -0700 Subject: [PATCH] ffi/unsafe/objc docs: clarification on `import-class' Merge to v5.3.2 (cherry picked from commit 2adf0bdf2e9024ba2d1bf86ca3ace915e07011b0) --- collects/scribblings/foreign/objc.scrbl | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/collects/scribblings/foreign/objc.scrbl b/collects/scribblings/foreign/objc.scrbl index eb88d245a4..5c04509f9d 100644 --- a/collects/scribblings/foreign/objc.scrbl +++ b/collects/scribblings/foreign/objc.scrbl @@ -107,6 +107,23 @@ Defines each @racket[class-id] to the class (a value with FFI type @examples[ #:eval objc-eval (eval:alts (import-class NSString) (void)) +] + +A class accessed by @racket[import-class] is normally declared as a +side effect of loading a foreign library. For example, if you want to +import the class @tt{NSString} on Mac OS X, the @filepath{Foundation} +framework must be loaded, first. Beware that if you use +@racket[import-class] in DrRacket or a module that @racket[require]s +@racketmodname[racket/gui/base], then @filepath{Foundation} will have +been loaded into the Racket process already. To avoid relying on other +libraries to load @filepath{Foundation}, explicitly load it with +@racket[ffi-lib]: + +@examples[ +#:eval objc-eval +(eval:alts (ffi-lib + "/System/Library/Frameworks/Foundation.framework/Foundation") (void)) +(eval:alts (import-class NSString) (void)) ]} @defform[(import-protocol protocol-id ...)]{