Module: Bacon::Helpers
- Included in:
- Context
- Defined in:
- lib/mac_bacon/helpers.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.converted_xibs ⇒ Object
5 6 7 |
# File 'lib/mac_bacon/helpers.rb', line 5 def self.converted_xibs @converted_xibs ||= {} end |
.ensure_nib(path) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/mac_bacon/helpers.rb', line 9 def self.ensure_nib(path) if File.extname(path) == '.xib' if cached = Helpers.converted_xibs[path] cached else xib_path, nib_path = path, File.join(Dir.tmpdir, "#{Time.now.to_i}.nib") unless system("/usr/bin/ibtool '#{xib_path}' --compile '#{nib_path}'") raise "Unable to convert XIB (to temporary NIB) at path `#{xib_path}'" end Helpers.converted_xibs[xib_path] = nib_path nib_path end else path end end |
Instance Method Details
#load_nib(nib_path, files_owner) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/mac_bacon/helpers.rb', line 26 def load_nib(nib_path, files_owner) nib_path = Helpers.ensure_nib(nib_path) url = NSURL.fileURLWithPath(nib_path) nib = NSNib.alloc.initWithContentsOfURL(url) top_level_objects = [] nameTable = { NSNibOwner => files_owner, NSNibTopLevelObjects => top_level_objects } nib.instantiateNibWithExternalNameTable(nameTable) top_level_objects end |