Joy Online Manual

NAME
ObjC.unteach - Remove Objective-C methods implemented in JavaScript

SYNOPSIS

ObjC.unteach(object, "selector")
ObjC.unteach(object)
ObjC.unteach()

delete object.selector

delete object["selector:selector:..."]

DESCRIPTION
Removes the JavaScript implementation of the method selector from the Objective-C object or class object, if it was added by the current interpreter. Any former implementation of a selector that was overridden will then reappear.

ObjC.unteach(object) removes all methods of the specified object or class that were added by the current interpreter. ObjC.unteach() will remove all methods that were added by the current interpreter from all objects and classes (this happens automatically if an interpreter is released).

The unteach method returns the number of method implementations that were successfully removed.

Alternatively to calling the unteach method, you can use JavaScript's delete  operator. If the selector contains colons you have to quote it and use array notation.

EXAMPLE

js> @teach NSObject test { return "test0" } @end
js> w = [[NSWindow alloc] init]
(NSWindow *)0x32b2f8
js> @teach w test { return "test1" } @end
js> w.test()
test1
js> @teach w test { return "test2" } @end
js> w.test()
test2
js> delete w.test
true
js> w.test()
test1
js> delete w.test
true
js> w.test()
test0

SEE ALSO

@teach

Index