开发者

MacRuby xcode label not working

class HelloApp
        attr_accessor :label, :text_field, :button
        def clickedButton(sender)
            # implementation
            your_name = self.text_field.stringValue
            self.label.stringValue = "Hello开发者_运维百科,  #{your_name}"
        end
end

The above code is in HelloApp.rb The problem is when I type something into the textbox, and click the button, the label just says "Hello, " and not "Hello, namegoeshere" I am using MacRuby .4 by the way.


Your code works for me in MacRuby .5

Does this log the user input to the console?

your_name = self.text_field.stringValue
puts "Your name is #{your_name}" 

If not, you may not have the text_field hooked up to the NSTextField in Interface Builder.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜