[MacRuby-devel] Monkey patching Objective-C classes

Laurent Sansonetti lsansonetti at apple.com
Fri Aug 21 14:39:46 PDT 2009


On Aug 21, 2009, at 2:06 PM, Clay Bridges wrote:
> 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. ;)

It seems to be fixed in trunk :-)

Laurent


More information about the MacRuby-devel mailing list