From: Satoshi N. <sna...@in...> - 2007-12-05 02:06:23
|
Hi, Actually, it is the right way now. > The only difference is, that you convert the NSCFString to String. > Is this step very important? If the NSString has been autoreleased, > will Ruby retain it to keep the AutoreleasePool from dealloc-ing? No. The step is unnecessary in this case. Because to_s will be called for all parameters in instance_eval. For the latter question, yes. Ruby will keep the NSString after the autorelease. You can make a test by yourself like: class AppController < OSX::NSObject def awakeFromNib OSX::TestObject.callback(self) p @s end def keep(s) @s = s end end @implementation TestObject + (void)callback:(id)sender { NSString* s = [[NSString alloc] initWithString:@"foobar"]; [sender keep:s]; [s release]; } @end -- Satoshi Nakagawa On 2007/12/05, at 10:19, Stefan Mueller wrote: > Hello > > Thanks for the quick answer. It looks like the workaround, > that I mentioned at the end of my message was actually the > right way to do it. > > The only difference is, that you convert the NSCFString to String. > Is this step very important? If the NSString has been autoreleased, > will Ruby retain it to keep the AutoreleasePool from dealloc-ing? > > > Knowing about objc_method will also be useful. > > > stefan mueller > > > On Dec 5, 2007, at 01:32 , Satoshi Nakagawa wrote: > >> Hi, >> >> For example, you need to make a callable method from ObjC in a ruby >> class: >> >> def evalScript_source(script, source) >> instance_eval(script.to_s, source.to_s) >> end >> >> -- >> Satoshi Nakagawa >> >> On 2007/12/05, at 6:50, Stefan Mueller wrote: >> >>> Hello >>> >>> >>> I've made a proxy method that's a better fit for bridge and then >>> calls the Ruby method, >>> but I don't think it's ideal. >>> >>> def evaluate_source(script, source) >>> self.instance_eval(script, source) >>> end >>> >>> regards, >>> Stefan Mueller >> > > > ------------------------------------------------------------------------- > SF.Net email is sponsored by: The Future of Linux Business White Paper > from Novell. From the desktop to the data center, Linux is going > mainstream. Let it simplify your IT future. > http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4 > _______________________________________________ > Rubycocoa-talk mailing list > Rub...@li... > https://lists.sourceforge.net/lists/listinfo/rubycocoa-talk |