I just started learning ruby motion and at the beginning of a tutorial I have hit a road block! The tutorial is "RubyMotion iOS Development Essentials".
Here is my code:
class RootController < UIViewController
def viewDidLoad
alert = UIAlertView.alloc.initWithTitle "This is foo title",
message:"Do you like this example?",
delegate: nil,
cancelButtonTitles: "cancel",
otherButtonTitles: "Yes", "No", nil
alert.show
end
end
I know the indentation looks funny, but apparently that is RubyMotion syntax... Weird, I know. And here is the error I am receiving, regarding the "initWithTitle" method:
(main)> 2013-12-13 00:44:40.780 HelloWorld[97435:80b] root_controller.rb:7:in `viewDidLoad': undefined method `initWithTitle' for #<UIAlertView:0x8d2bcf0> (NoMethodError)
from app_delegate.rb:6:in `application:didFinishLaunchingWithOptions:'
2013-12-13 00:44:40.782 HelloWorld[97435:80b] root_controller.rb:7:in `viewDidLoad': undefined method `initWithTitle' for #<UIAlertView:0x8d2bcf0> (NoMethodError)
from app_delegate.rb:6:in `application:didFinishLaunchingWithOptions:'
2013-12-13 00:44:40.784 HelloWorld[97435:80b] *** Terminating app due to uncaught exception 'NoMethodError', reason: 'root_controller.rb:7:in `viewDidLoad': undefined method `initWithTitle' for #<UIAlertView:0x8d2bcf0> (NoMethodError)
from app_delegate.rb:6:in `application:didFinishLaunchingWithOptions:'
'
I would appreciate any pointers, it's a major bummer to get stuck this early on!
cancelButtonTitles
should be singular: cancelButtonTitle
.
Because you're using plural wording, it can't find a matching method signature.