Skip to content

Commit d450ff9

Browse files
mflattrmculpepper
authored andcommitted
ffi/unsafe/objc docs: clarification on `import-class'
Merge to v5.3.2 (cherry picked from commit 2adf0bd)
1 parent 48380b4 commit d450ff9

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

collects/scribblings/foreign/objc.scrbl

+17
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,23 @@ Defines each @racket[class-id] to the class (a value with FFI type
107107
@examples[
108108
#:eval objc-eval
109109
(eval:alts (import-class NSString) (void))
110+
]
111+
112+
A class accessed by @racket[import-class] is normally declared as a
113+
side effect of loading a foreign library. For example, if you want to
114+
import the class @tt{NSString} on Mac OS X, the @filepath{Foundation}
115+
framework must be loaded, first. Beware that if you use
116+
@racket[import-class] in DrRacket or a module that @racket[require]s
117+
@racketmodname[racket/gui/base], then @filepath{Foundation} will have
118+
been loaded into the Racket process already. To avoid relying on other
119+
libraries to load @filepath{Foundation}, explicitly load it with
120+
@racket[ffi-lib]:
121+
122+
@examples[
123+
#:eval objc-eval
124+
(eval:alts (ffi-lib
125+
"/System/Library/Frameworks/Foundation.framework/Foundation") (void))
126+
(eval:alts (import-class NSString) (void))
110127
]}
111128

112129
@defform[(import-protocol protocol-id ...)]{

0 commit comments

Comments
 (0)