Creating Sheets with RubyCocoa
Here’s another example from Tim Perrett; this one uses RubyCocoa to display a sheet in a window.
You can download a zip file here. After you unpack it, open and build the enclosed Xcode project.
The interesting Ruby code is in the MainController class, defined in MainController.rb.
Quoting Tim:# This class is instantiated in the MainMenu.nib file, and subsequently linked # up in IB to the main window (the mainWindow outlet) # But, and this is a big but - its where I was going wrong for quite some time; # if you look in the secondary nib file, you can see that the panel nib's # file owner is this class but there it is not instantiated, but merely referenced # so IB is aware of its existence. # # I must give a shout to Sherm, the inventor of CamelBones (a perl/cocoa bridge) # as he has been so so so helpful in getting this working using RubyCocoa. # I think this is one of the most important concepts when using IB, that of nibs # with no instantiated class and its where a lot of people, including myself, # go wrong. # # Cheers everyone, Tim.This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 2.5 License.
What do you think of this book? Post your comment or suggestion below!

Comments (0) post