jeanp****@gmail*****
jeanp****@gmail*****
Fri Jan 5 09:15:22 JST 2007
On 1/4/07, Tim Burks <tim****@neont*****> wrote: > > Hi Jean Pierre, > > On Jan 4, 2007, at 3:13 PM, jeanp****@gmail***** wrote: > […] > > > > LoadError: Failed to lookup Init function ./schoolkid.bundle > > > > exactly the same code, just using a different bundle name... > > > > You need an Init_* function in your ObjC code. Change "Init_Client" > to "Init_YourNewBundleName". that would certainly explain it, thanks for the tip, i'm not sure how i managed to miss exactly what the init function was for =) > [2] is rubycocoa doing some sort of memory management on allocated > > objC objects? i thought with 0.5 that if i allocated and > > initialized an objC derived object that i'd also need to release > > it, but with 0.9, doing so causes a segfault. > > > > kid = OSX::SchoolKid.alloc.init > > kid.release > > > > Don't do that. That will overrelease kid. RubyCocoa won't detect > that the retain that you just sent caused the underlying object to be > deleted. okay, so ruby will garbage collect the objects created in ruby regardless of the object type? > > > [3] should i be able to override objC methods in ruby? if i have > > some objC class: > […] > > I've found the same problem, it's related to the trick that is being > used to automatically import the class. When it automatically > imports a class in a class declaration, the wrong class is used when > the body of the class is parsed. > > For example, add this "puts" to your code and rerun it (or use > OSX.NSLog). > > > class OSX::SchoolKid > puts self.superclass > > def saySomething > > puts "hi" > > end > > end > > You'll probably see that it's "Object" instead of OSX::NSObject. indeed you are right. > > > [4] is OSX.ns_import no longer required? > > > > generally, but you can use it to work around the above problem. > Just OSX.ns_import :SchoolKid before you open the class for > modification. excellent! thanks for the help, that'll get me well on my way to using rspec and mocking my objC projects =) cheers, jean-pierre -------------- next part -------------- An HTML attachment was scrubbed... Descargar