Re: [F-Script-talk] adding Blocks as methods to ObjC classes
Brought to you by:
pmougin
From: Philippe M. <pm...@ac...> - 2005-02-20 17:49:24
|
Le 15 f=E9vr. 05, =E0 09:05, Ken Ferry a =E9crit : > I do think that JGType steals some (most?) of the thunder here, but I > haven't had much luck getting JGType to work. My app crashes whenever > I try to use the dynamic subclassing. Can we get a little bit of > sample code on that? Hi Ken, Here is a basic example where we create a new subclass of NSObject,=20 named MyClass, with three instance variables named a, b and c, and=20 define a simple method named method1: > NSObject subclass:'MyClass' instanceVariableNames:'a b c' MyClass > MyClass MyClass > MyClass setFSBlock:[:self :_cmd| 'Method ' ++ _cmd ++ ' called on '=20= ++ self printString] asInstanceMethod:#method1 > myInstance :=3D MyClass alloc init > myInstance method1 'Method method1 called on <MyClass: 0x4bb69c0>' Best, Philippe Mougin= |