[MacRuby-devel] Monkey patching Objective-C classes

Clay Bridges diffengr at gmail.com
Fri Aug 21 14:06:55 PDT 2009


Forgive my caveman-programmer terminology, but it seems to overwrite
the class symbol. Extending Laurent's example (kind of):

gort:~ clay$ macruby -e "p NSPredicate.object_id; p
NSPredicate.methods(false,true); class NSPredicate; def hey;end; end;
p NSPredicate.object_id; p NSPredicate.methods(false,true)"

140735077844512
[:predicateWithValue, :predicateWithFormat:arguments:,
:predicateWithFormat, :predicateWithFormat:argumentArray:,
:newStringFrom:usingUnicodeTransforms:, :initialize]
4298735808
[:__new__, :new, :alloc]

gort:~ clay$ macruby --version
MacRuby version 0.4 (ruby 1.9.1) [universal-darwin9.5, x86_64]

If it's fixed, it still might be worth a unit test. ;)

Clay


More information about the MacRuby-devel mailing list