(use objc) (define-objc-class MyPoint NSObject ((DBL x) (DBL y)) (define-method ID init (print "MyPoint init") self) (define-method DBL getX (ivar-ref self x)) (define-method DBL getY @y) (define-method VOID print (print "(" @x ", " (ivar-ref self y) ")")) (define-method VOID ((moveByX: DBL a) (Y: DBL b)) (set! @x (+ a @x)) (ivar-set! self y (+ b (ivar-ref self y)))) ;(- VOID dealloc (print "deallocating " self)) ;; temporary ) ;; This is here because there was previously memory corruption upon ;; adding many methods (now fixed). (define-objc-class MethTest NSObject () (- ID init @[super init] (print "MethTest init") self) (- ID test (print "methtest") self) (- ID test2 (gc) (print "methtest") self) (- ID test3 (print "methtest") self) (- ID test4 (print "methtest") self) (- ID test5 (print "methtest") self) (- ID test6 (print "methtest") self) (- ID test7 (print "methtest") self) (- ID test8 (print "methtest") self) (- ID test9 (print "methtest") self) (- ID test10 (print "methtest") self) (- ID test11 (print "methtest") self) (- ID test12 (print "methtest") self) (- VOID ((printArg: ID arg)) ;(gc #t) (print @[arg retainCount]) ;(print @[arg length]) (void)) (- VOID ((printDArg: DBL arg)) ;(gc #t) ;(print @[arg retainCount]) ;(print @[arg length])) (void)) (+ ID newobject @[MethTest alloc]) ; (- VOID dealloc (print "deallocating " self) ;@[super dealloc] ;; crash ; ) ; (- VOID release (print "release MethTest") (objc-release (objc:instance->pointer self))) ;; DNW (+ ID alloc ; ; @[@[super alloc] retain] (print "methtest alloc") @[super alloc]) ) (define p @[MyPoint alloc]) ;(let ((m @[MethTest alloc])) @[m printArg: p] (void)) ;; ok ;(let ((m @[MethTest alloc])) @[m printArg: p]) ;; not ok