Skip to content

Commit 7f911f0

Browse files
committed
with withExtendedLifetime
1 parent 850a801 commit 7f911f0

File tree

15 files changed

+96
-88
lines changed

15 files changed

+96
-88
lines changed

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,16 @@ a Base class and Proxy is generated for the concrete class that can be subclasse
178178

179179
As these "Base" subclasses can't close over variables in your program you may want to
180180
have an initialiser to capture these instead. There is a bit of a standard dance
181-
that needs to be performed. First, instantiate the "Base" superclass and pass this
182-
to the designated initialiser of your superclass. Due to the use of generics you'll
181+
that needs to be performed. Instantiate the "Base" superclass and assign it's
182+
javaObject to your classes' javaObject. Due to the use of generics you'll
183183
also be prompted to provide a null implementation of the "required" initialiser.
184184

185185
```Swift
186186
init(imageProducer:ImageProducer) {
187-
super.init( javaObject: CanvasBase().takeJavaObject )
187+
super.init(javaObject: nil)
188+
withExtendedLifetime(CanvasBase()) {
189+
javaObject = $0.javaObject
190+
}
188191
image = createImage(imageProducer)
189192
}
190193

com_apple

genie.jar

-2 Bytes
Binary file not shown.

java_awt

java_lang

java_sql

java_swift

java_util

javax_swing

0 commit comments

Comments
 (0)