From: Hunter K. <re...@gm...> - 2006-02-17 23:43:15
|
Hiya, I'm fairly new to Cocoa programming. I'm using XCode + Interface Builder, and have been working through "Cocoa Programming for Mac OS X". I'm a long time ruby fan, and have started playing around with the RubyCocoa bindings. Ruby and Objective-C look like a really natural fit, and the binding seems really good. However, I'm having a problem figuring out what I assume must be a pretty simple thing - how do I make a Interface Builder "see" my ruby classes, so I can create an instance of it, and tie it into the nib file? For example, I opened up the simpleapp example. Interface Builder can "see" AppController and MyView. However, in XCode, if I create a new Ruby subclass of NSObject, I can't figure out how to tell Interface Builder about this new class. If it were Obj-C, I'd just drag the .h file onto Interface Builder, but when I try that with the .rb file Interface Builder flicks over to the sounds tab or something. What do I need to be able to do to make Interface Builder aware of my Ruby classes? Cheers, Hunter |
From: Jonathan P. <jp...@dc...> - 2006-02-17 23:52:32
|
On 17 Feb 2006, at 14:53, Hunter Kelly wrote: > For example, I opened up the simpleapp example. Interface Builder can > "see" AppController and MyView. However, in XCode, if I create a new > Ruby subclass of NSObject, I can't figure out how to tell Interface > Builder about this new class. If it were Obj-C, I'd just drag the .h > file onto Interface Builder, but when I try that with the .rb file > Interface Builder flicks over to the sounds tab or something. > > What do I need to be able to do to make Interface Builder aware of my > Ruby classes? You can do it manually in Interface Builder. You need to create a =20 subclass of NSObject with the appropriate name, and then instantiate =20 it. This is described in the Interface Builder help. I've pasted a =20 fragment of it below. You'll have to add the actions and outlet names =20= manually too. Hope that helps, Jonathan Creating a Class To create a class that inherits from a Coca class, follow the steps =20 in each of these sections, in order: =93Subclass an existing class.=94 =93Add actions and outlets to the new class.=94 =93Create an instance of the new class.=94 =93Connect the class=92s actions and outlets.=94 =93Generate the class=92s source code files.=94 Subclass an existing class. In the Classes pane of the nib file window, Control-click the class =20 you want your class to inherit from, and choose Subclass from the =20 menu that appears. A new subclass is added with a default name. Type =20 in a new name for the subclass. ... |
From: Hunter K. <re...@gm...> - 2006-02-20 09:53:25
|
Yah, I figured as much over the weekend. Thanks for the reply though... Does Interface Builder have some kind of hook that we could modify to make it recognize .rb files? Even cooler would be a way to tell it that it would be a ruby file, and have it generate the skeleton .rb file... H On 2/17/06, Jonathan Paisley <jp...@dc...> wrote: > On 17 Feb 2006, at 14:53, Hunter Kelly wrote: > > > For example, I opened up the simpleapp example. Interface Builder can > > "see" AppController and MyView. However, in XCode, if I create a new > > Ruby subclass of NSObject, I can't figure out how to tell Interface > > Builder about this new class. If it were Obj-C, I'd just drag the .h > > file onto Interface Builder, but when I try that with the .rb file > > Interface Builder flicks over to the sounds tab or something. > > > > What do I need to be able to do to make Interface Builder aware of my > > Ruby classes? > > You can do it manually in Interface Builder. You need to create a > subclass of NSObject with the appropriate name, and then instantiate > it. This is described in the Interface Builder help. I've pasted a > fragment of it below. You'll have to add the actions and outlet names > manually too. > > Hope that helps, > Jonathan > > > Creating a Class > > To create a class that inherits from a Coca class, follow the steps > in each of these sections, in order: > > "Subclass an existing class." > "Add actions and outlets to the new class." > "Create an instance of the new class." > "Connect the class's actions and outlets." > "Generate the class's source code files." > > Subclass an existing class. > > In the Classes pane of the nib file window, Control-click the class > you want your class to inherit from, and choose Subclass from the > menu that appears. A new subclass is added with a default name. Type > in a new name for the subclass. > > ... > > > > |
From: Jonathan P. <jp...@dc...> - 2006-02-20 10:13:13
|
On 20 Feb 2006, at 9:27, Hunter Kelly wrote: > Does Interface Builder have some kind of hook that we could modify to > make it recognize .rb files? Even cooler would be a way to tell it > that it would be a ruby file, and have it generate the skeleton .rb > file... I don't think so. However, it's possible that you could do the drive Interface Builder via AppleScript to create the classes as required. You could probably also create a ruby script that parses the output from 'nibtool -c' (and other options) to create a skeleton .rb file. |