Tag: macruby

MacRuby自定义初始化程序

刚刚今天下午发现了MacRuby; 男人是那么酷! 但是,我试图用一些MacRuby-fu扩展旧项目时遇到了一些困难。 这是交易: 所以我在Objective-C中有一个超类,如下所示: @implementation Foo – (id) init { if (self = [super init]) { //Do nothing, don’t have enough data… } return self; } – (id) initWithName:(NSString*)n andLocation:(NSString*)loc andSomethingElse:(Bar*)b { if (self = [super init]) { //Set a LOT of internal state… } return self; } @end 因此,在ruby文件中,我们将其称为Mung.rb,如下所示: class Mung < Foo […]

使用Cocoa框架时,MacRuby指针,引用,解除引用

在MacRuby指向typedef结构的指针上 ,我学会了如何取消引用用它创建的指针 x=Pointer.new_with_type … ==> use x.value, or x[0] 干得好吃! 现在我想学习我认为的“对立面”。 我正在尝试使用此API。 OSStatus SecKeychainCopySettings ( SecKeychainRef keychain, SecKeychainSettings *outSettings ); 第二个参数必须是指针。 但我从来没有设法打开钥匙链的真实outSettings,我只获得默认设置。 framework ‘Security’ keychainObject = Pointer.new_with_type(‘^{OpaqueSecKeychainRef}’) SecKeychainOpen(“/Users/charbon/Library/Keychains/Josja.keychain”,keychainObject) #attempt #1 settings=Pointer.new_with_type(‘{SecKeychainSettings=IBBI}’) SecKeychainCopySettings(keychainObject.value, settings) p settings.value # #attempt #2 settings2=SecKeychainSettings.new result = SecKeychainCopySettings(keychainObject.value, settings2) p settings2 # 应阅读钥匙串的设置 # 我错过了什么?

嵌套类如何在Ruby中访问外部类中的方法?

def class A def a raise “hi” #can’t be reached end class B def b a() #doesn’t find method a. end end end 我想从b调用a并引发exception。 我怎么能够?

学习MacRuby的好资源

我不懂Ruby,我有兴趣学习MacRuby。 你会推荐什么样的最佳资源(书籍,博客,网站)? 发现: http : //www.macruby.org/ 更多信息来自rubyconf.org Macruby talk

MacRuby,使用续集时出错

我刚刚使用命令sudo macgem install sequel安装了Sequel 。 它告诉我sequel-3.18.0已成功安装。 当我启动xcode并启动新的MacRuby应用程序时,它会为unit testing设置目标。 我用以下两行修改了stub_test.rb : require “rubygems” require “sequel” 尝试运行unit testing时,出现以下错误: /Users/…/macRuby Test/Tests/run_suite.rb:1:in `’: super: no superclass method `require’ for Sequel:Class (NoMethodError) 没有两个require语句,测试运行正常。 我试图谷歌这个,并在macruby.org上找到以下票 : 机票#930 SIGABRT在MacRuby 0.7中使用Sequel + SQLite3-Ruby gem […]在Sequel修补内核#require问题后,我可以加载Sequel和SQLite3,没有任何问题。 […]必需的库是Sequel(Patched for Kernel.require,而不是Sequel#self.require中的super)和SQLite3-Ruby。 […] 我在其他地方找不到关于这个补丁的任何信息,不过…… 有没有已知的问题? 这个错误消息意味着什么,以及我如何让它工作?

Interface Builder没有看到MacRuby的出口

我试图使用XCode和Interface Builder获得一个基本的hello world应用程序。 但是,在Interface Builder中,我无法看到我的sockets连接起来。 我转到对象检查器窗格的连接选项卡,并显示“New Referencing Outlet”。 我想知道我的代码是否错误。 这里是 class HelloWorldController attr_accessor :hello_label, :hello_button, :hello def awakeFromNib @hello = true end def changeLabel(sender) if @hello @hello_label.stringValue = “Good Bye” @hello_button.title = “Hello” @hello = false else @hello_label.stringValue = “Hello World” @hello_button.title = “Good Bye” @hello = true end end end 据我了解,我应该能够看到你好,hello_label,hello_button和changeLabel,但我没有。 我想也许我在某个地方拼错了,但这似乎也不是。 这是两个界面构建器窗口的镜头。 任何帮助表示赞赏。 […]

我应该学习MacRuby还是RubyCocoa

我想用ruby学习mac开发但是我不确定要去哪一个。 RubyCocoa已经存在了很长时间,但我认为MacRuby将在长期内击败它。 有什么建议??