From: Wolfgang K. <kit...@ka...> - 2010-03-19 07:45:39
|
I run into an other challenge with the bridge: When initializing a subclass of NSViewController, the bridge claims, that super:initWithNibName:bundle: is a missing method. Here an sample irb session: >> require 'osx/cocoa' => true >> include OSX => Object >> class VC < NSViewController >> def init >> super_initWithNibName_bundle('dummy',nil) >> end >> end => nil >> vc = VC.alloc.init OSX::OCMessageSendException: Can't get Objective-C method signature for selector 'super:initWithNibName:bundle:' of receiver #<VC:0x8093c60c class='VC' id=0x101edeb30> from /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/oc_wrapper.rb:50:in `ocm_send' from /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/oc_wrapper.rb:50:in `method_missing' from (irb):5:in `init' from (irb):8 >> I can verify the presence of the initWithNibName:bundle: method >> VC.superclass => OSX::NSViewController >> VC.objc_instance_methods.sort ...,"infoForBinding:", "init", "initWithCoder:", "initWithNibName:bundle:", "insertText:",... What is my fault? Best regards Wolfgang Kittenberger |
From: Allison N. <dem...@ma...> - 2010-03-19 08:12:51
|
Wolfgang, When you want to call a super method, you have to do it from inside a method having exactly the same signature/name. So this works: >> class VC >> def initWithNibName_bundle(nibname, bundle) >> super_initWithNibName_bundle(nibname, bundle) >> end >> end => nil >> vc = VC.alloc.initWithNibName_bundle('dummy', nil) => #<VC:0x32e416 class='VC' id=0x1a001c0> If you really want to have just a plain init method, you could then define it as: def init initWithNibName_bundle('dummy, nil) end > vc = VC.alloc.init => #<VC:0x31c306 class='VC' id=0x1a24210> Please note that the signature of the method really does have to be identical, with the same number of parameters. Alli Le 19 mars 10 à 08:44, Wolfgang Kittenberger a écrit : > I run into an other challenge with the bridge: > > When initializing a subclass of NSViewController, the bridge claims, > that super:initWithNibName:bundle: is a missing method. > > Here an sample irb session: >>> require 'osx/cocoa' > => true >>> include OSX > => Object >>> class VC < NSViewController >>> def init >>> super_initWithNibName_bundle('dummy',nil) >>> end >>> end > => nil >>> vc = VC.alloc.init > OSX::OCMessageSendException: Can't get Objective-C method signature > for selector 'super:initWithNibName:bundle:' of receiver #<VC: > 0x8093c60c class='VC' id=0x101edeb30> > from /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/ > objc/oc_wrapper.rb:50:in `ocm_send' > from /Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/ > objc/oc_wrapper.rb:50:in `method_missing' > from (irb):5:in `init' > from (irb):8 >>> > > I can verify the presence of the initWithNibName:bundle: method > >>> VC.superclass > => OSX::NSViewController >>> VC.objc_instance_methods.sort > ...,"infoForBinding:", "init", "initWithCoder:", > "initWithNibName:bundle:", "insertText:",... > > What is my fault? > > Best regards > Wolfgang Kittenberger > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > Rubycocoa-talk mailing list > Rub...@li... > https://lists.sourceforge.net/lists/listinfo/rubycocoa-talk |
From: Wolfgang K. <kit...@ka...> - 2010-03-19 10:12:16
|
Alli, Thanks for the fast response and your advice. Is this a requirement specific for the Rubycocoa bridge? I found in the Hillegass book (3rd edition) on page 359 an Objective-C code snippet like this: @implementation DepartmentViewController - (id)init { if (![super initWithNibName:@"DepartmentView" bundle:nil]) return nil; [self setTitle:@"Departments"]; return self; } @end best regards Wolfgang |
From: Allison N. <dem...@ma...> - 2010-03-19 10:16:33
|
Yup, its a bridge thing. You'll notice that the init method that I defined in the last post does the same thing as the hillegass example. As long as you stay on one side of the bridge or the other, you can do as you please, but as soon as you cross the bridge using super_ you have to keep the same signature. Envoyé de mon iPhone Le 19 mars 2010 à 11:11, Wolfgang Kittenberger <kit...@ka...> a écrit : > Alli, > > Thanks for the fast response and your advice. > > Is this a requirement specific for the Rubycocoa bridge? > I found in the Hillegass book (3rd edition) on page 359 an > Objective-C code snippet like this: > > @implementation DepartmentViewController > > - (id)init > { > if (![super initWithNibName:@"DepartmentView" > bundle:nil]) > return nil; > [self setTitle:@"Departments"]; > return self; > } > > @end > > > best regards > Wolfgang > > --- > --- > --- > --------------------------------------------------------------------- > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > Rubycocoa-talk mailing list > Rub...@li... > https://lists.sourceforge.net/lists/listinfo/rubycocoa-talk |
From: Wolfgang K. <kit...@ka...> - 2010-03-19 11:28:09
|
Great, the first step of the Hillegass example 29_ViewSwapping works now with the adapted initialization. Many thanks again Wolfgang |
From: Eric C. <ech...@gm...> - 2010-03-20 20:56:04
|
On Fri, Mar 19, 2010 at 5:15 AM, Allison Newman <dem...@ma...> wrote: > Yup, its a bridge thing. You'll notice that the init method that I defined > in the last post does the same thing as the hillegass example. As long as > you stay on one side of the bridge or the other, you can do as you please, > but as soon as you cross the bridge using super_ you have to keep the same > signature. Is the bridge also the reason you can't just use super(...)? |
From: Allison N. <dem...@ma...> - 2010-03-20 23:02:57
|
I'm not an expert, but super will call the superclass in ruby. It might be a bridge proxy object, not the cocoa "superclass". Sorry I'm not in front of a computer, so I can't check the source, but I'm guessig that's why super_xxxx is used Hope that helps. Envoyé de mon iPhone Le 20 mars 2010 à 21:55, Eric Christopherson <ech...@gm...> a écrit : > On Fri, Mar 19, 2010 at 5:15 AM, Allison Newman <dem...@ma...> > wrote: >> Yup, its a bridge thing. You'll notice that the init method that I >> defined >> in the last post does the same thing as the hillegass example. As >> long as >> you stay on one side of the bridge or the other, you can do as you >> please, >> but as soon as you cross the bridge using super_ you have to keep >> the same >> signature. > > Is the bridge also the reason you can't just use super(...)? > > --- > --- > --- > --------------------------------------------------------------------- > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > Rubycocoa-talk mailing list > Rub...@li... > https://lists.sourceforge.net/lists/listinfo/rubycocoa-talk |
From: Wolfgang K. <kit...@ka...> - 2010-03-21 21:02:02
|
Hi Eric, The answer to your question I found the book "Programming Cocoa with Ruby" (Brian Marik) on the pages 98ff: A method super_foo calls the method foo in the first Objective-C ancestor class. The pseudomethod super calls the first Ruby ancestor. myMini-2:rubycocoa-oddities kittekat$ more super-and-super.rb #--- # Excerpted from "RubyCocoa", # published by The Pragmatic Bookshelf. # Copyrights apply to this code. It may not be used to create training material, # courses, books, articles, and the like. Contact us if you are in doubt. # We make no guarantees that this code is fit for any purpose. # Visit http://www.pragmaticprogrammer.com/titles/bmrc for more book information. #--- require 'osx/cocoa' # This file shows that the RubyCocoa super_x way of calling a # superclass method ONLY looks in an Objective-C object, not a # superclass that's defined in Ruby. class RubyFromObjC < OSX::NSObject def description "Some kind of RubyFromObjC" end end class RubyFromRuby < RubyFromObjC def description "super_description says: " + super_description + "\nbut super says: " + super + "\nThe super_description comes from NSObject#description." end end if $0 == __FILE__ puts RubyFromRuby.alloc.init.description end myMini-2:rubycocoa-oddities kittekat$ ruby super-and-super.rb super_description says: <RubyFromRuby: 0x1018f8ba0> but super says: Some kind of RubyFromObjC The super_description comes from NSObject#description. myMini-2:rubycocoa-oddities kittekat$ Regards Wolfgang |
From: Eric C. <ech...@gm...> - 2010-03-22 20:44:54
|
On Sun, Mar 21, 2010 at 4:01 PM, Wolfgang Kittenberger <kit...@ka...> wrote: > Hi Eric, > The answer to your question I found the book "Programming Cocoa with Ruby" > (Brian Marik) on the pages 98ff: > A method super_foo calls the method foo in the first Objective-C ancestor > class. > The pseudomethod super calls the first Ruby ancestor. [...] > myMini-2:rubycocoa-oddities kittekat$ ruby super-and-super.rb > super_description says: <RubyFromRuby: 0x1018f8ba0> > but super says: Some kind of RubyFromObjC > The super_description comes from NSObject#description. > myMini-2:rubycocoa-oddities kittekat$ > Regards > Wolfgang Thanks! |