What is the rules about optional method arguments in
NSObject-subclasses? I recently upgraded from 0.13.1 to 1.0.0 and this
problem appeared:
class Subtitle < NSObject
def filename(add_language = false) # notice optional arg here!
# ...
end
end
When using "Build & Go" from Xcode it crashes immediately with this error:
[...]/build/Debug/Undertext.app/Contents/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/oc_import.rb:346:in
`_ns_behavior_method_added': Cannot override Objective-C method
'filename' with Ruby method #filename, they should both have the same
number of arguments. (expected arity 0, got -1) (RuntimeError)
from [...]/build/Debug/Undertext.app/Contents/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/oc_import.rb:684:in
`method_added'
from [...]/build/Debug/Undertext.app/Contents/Resources/Subtitle.rb:25
from [...]/build/Debug/Undertext.app/Contents/Resources/rb_main.rb:17:in
`require'
from [...]/build/Debug/Undertext.app/Contents/Resources/rb_main.rb:17:in
`rb_main_init'
from [...]/build/Debug/Undertext.app/Contents/Resources/rb_main.rb:16:in `each'
from [...]/build/Debug/Undertext.app/Contents/Resources/rb_main.rb:16:in
`rb_main_init'
from [...]/build/Debug/Undertext.app/Contents/Resources/rb_main.rb:22
When removing the argument or removing the default-value (ie. false) I
get no error. My guess this is expected behaviour, but what is the
exact rules and why?
Sincerely,
Johan Lundström
joh...@gm...
|