#330: forwardingTargetForSelector not working properly in Objective-C classes loaded in MR --------------------------------+------------------------------------------- Reporter: diffe...@… | Owner: lsansone...@… Type: defect | Status: new Priority: major | Milestone: Component: MacRuby | Keywords: --------------------------------+------------------------------------------- Changes (by martinlagarde...@…):
* milestone: MacRuby 0.4 => Old description: > When using forwardingTargetForSelector: to create a wrapper class in > ObjC, it does not work in MacRuby. > > It's kind of a complicated setup, so I've created a minimal-ish project > in github containing ObjC and MacRuby code to illustrate the problem. > It's here: > > http://github.com/diffengr/macruby_forwarding_invocation_example > > That contains an XCode project and a rakefile. It has the ObjC classes > Candy and CandyWrapper, and they both have the NSString* property flavor. > CandyWrapper declares that property @dynamic, and forwards it to Candy. > > Here's the code that works in ObjC. > > Candy* rootBeerCandy = [[Candy alloc] init]; > rootBeerCandy.flavor = @"Root Beer"; > > CandyWrapper* rootBeerWrapper = [[CandyWrapper alloc] > initWithCandy:rootBeerCandy]; > NSLog(@"Candy#flavor \"%...@\", Wrapper#flavor \"%...@\"", > rootBeerCandy.flavor, > rootBeerWrapper.flavor); > > If you load and run the xcode project in this directory, you'll get this > output: > > NSLog[...] <CandyWrapper: 0x104fb0> forwarding flavor to <Candy: > 0x103380> > NSLog[...] Candy#flavor "Root Beer", Wrapper#flavor "Root Beer" > > Here's that same code instantiated in MacRuby, from candy_test.rb: > > rootBeerCandy = Candy.alloc.init > rootBeerCandy.flavor = 'Root Beer' > > rootBeerWrapper = CandyWrapper.alloc.initWithCandy rootBeerCandy > puts "Candy#flavor #{rootBeerCandy.flavor}, Wrapper#flavor > #{rootBeerWrapper.flavor}" > > You can run this with "macrake test" in the project directory, and it > will give (among other things): > > candy_test.rb:7:in `<main>': undefined method `flavor' for > #<CandyWrapper:0x8000aa2a0> (NoMethodError) > rake aborted! New description: When using forwardingTargetForSelector: to create a wrapper class in ObjC, it does not work in MacRuby. It's kind of a complicated setup, so I've created a minimal-ish project in github containing ObjC and MacRuby code to illustrate the problem. It's here: http://github.com/diffengr/macruby_forwarding_invocation_example That contains an XCode project and a rakefile. It has the ObjC classes Candy and CandyWrapper, and they both have the NSString* property flavor. CandyWrapper declares that property @dynamic, and forwards it to Candy. Here's the code that works in ObjC. {{{ Candy* rootBeerCandy = [[Candy alloc] init]; rootBeerCandy.flavor = @"Root Beer"; CandyWrapper* rootBeerWrapper = [[CandyWrapper alloc] initWithCandy:rootBeerCandy]; NSLog(@"Candy#flavor \"%...@\", Wrapper#flavor \"%...@\"", rootBeerCandy.flavor, rootBeerWrapper.flavor); }}} If you load and run the xcode project in this directory, you'll get this output: {{{ NSLog[...] <CandyWrapper: 0x104fb0> forwarding flavor to <Candy: 0x103380> NSLog[...] Candy#flavor "Root Beer", Wrapper#flavor "Root Beer" }}} Here's that same code instantiated in MacRuby, from candy_test.rb: {{{ rootBeerCandy = Candy.alloc.init rootBeerCandy.flavor = 'Root Beer' rootBeerWrapper = CandyWrapper.alloc.initWithCandy rootBeerCandy puts "Candy#flavor #{rootBeerCandy.flavor}, Wrapper#flavor #{rootBeerWrapper.flavor}" }}} You can run this with "macrake test" in the project directory, and it will give (among other things): {{{ candy_test.rb:7:in `<main>': undefined method `flavor' for #<CandyWrapper:0x8000aa2a0> (NoMethodError) rake aborted! }}} -- -- Ticket URL: <http://www.macruby.org/trac/ticket/330#comment:1> MacRuby <http://macruby.org/> _______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel