From: Eloy D. <elo...@gm...> - 2006-11-18 01:29:59
|
Hello, Like the subject says :) I'll give an example of what I would like to be able to do: class SomeClass < OSX::NSObject def self.active_table_view(tableViewName) ib_outlets tableViewName # Here I want to create a reference to the defined outlet instance_eval "@tableView = @#{tableViewName}" end def awakeFromNib # So that I could now do stuff like: @tableView.setDelegate(self) end end class SomeSubClass < SomeClass active_table_view :someTableView end At the moment I've hacked around it and it works, but it should be possible to do it in a better way right?.... The hack I use now is like: class SomeClass < OSX::NSObject def awakeFromNib # Loop through the instance variables and check for a NSTableView instance. # When found assign it to the instance variable @tableView. # Is this the way to do it? Or is there a way to intercept the symbol passed to ib_outlets? instance_variables.each do |obj| instance_eval " begin if #{obj}.isKindOfClass(OSX::NSTableView) @tableView = #{obj} end rescue end " end @tableView.setDelegate(self) end end Cheers, Eloy. |