Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Basic questions about Gorm

1 view
Skip to first unread message

Omar Campos

unread,
Apr 8, 2011, 4:57:05 PM4/8/11
to discuss...@gnu.org
Hi all,

  First I'd like to say that I'm still a newbie in all things Objective-C, so please excuse me if my questions sound too basic or just plain stupid. My only experience has been using Xcode on the Mac, and with UIKit (and have only used a few widgets about it so far). When using Gorm to draw a simple interface, the following doubts came up:

- I dragged a "Title" to my window, but I found no way to change its caption. The Inspector only allows to change the color and alignment properties. Does this need to be changed programatically?
- I found no way to create connections between outlets by dragging like I do in Xcode. How is this done? (It may simply be that I don't have any connectable properties yet!)
- Using @property for my controls had errors. Is this not supported in GNUStep? (It's OK, if it isn't, I don't have a problem with manually creating my properties).
- I am not exactly sure how do I get my Objective-C class inheriting from NSWindow to load the nib? In UIKit, I've seen this done with initWithNibName:bundle:, and even though I haven't successfully used it yet, I wonder if such a function exists in AppKit. Or do I need to inherit from NSWindowController instead.

If you guys can point me to a tutorial which shows how to do these things, that would work as well.

Thanks for any info, and again, sorry for the basic questions.

Sincerely,
Omar Campos Rivera


Omar Campos

unread,
Apr 8, 2011, 6:21:45 PM4/8/11
to discuss...@gnu.org
Hi again,

  Thanks for the clarifications. I will try out the tutorials you suggested. I don't mind creating my GUI from code.  On the contrary, I like to see how things work "under the hood". As an aside, thanks for being honest and open to my questions. I've participated in a few other open source communities where newbies were left to fend for themselves. I was even told once to "go read a book". But here in GNUStep's community, my questions have always been answered honestly and professionally, even though I've only asked once or twice before.

Thanks again. You guys are the best!

Sincerely,
Omar Campos Rivera

Riccardo Mottola

unread,
Apr 8, 2011, 6:34:35 PM4/8/11
to Omar Campos, discuss...@gnu.org
Hi,

> Hi all,
>
> First I'd like to say that I'm still a newbie in all things
> Objective-C, so please excuse me if my questions sound too basic or
> just plain stupid. My only experience has been using Xcode on the Mac,
> and with UIKit (and have only used a few widgets about it so far).
> When using Gorm to draw a simple interface, the following doubts came up:

I think you should familiarize with AppKit first. Do it on the mac with
a tutorial for 10.2 ... 10.4 and you should find concepts very similar
to GNUstep. and quite applicable. We support also 10.5 and 10.6
features, but the developer app paradigm did not follow apple's.
We still distinguish between the project builder and the interface
builder and I'm happy it is as it is, apple is changing many thing
gratuitously so it can make shiny new features which each release.


> - I dragged a "Title" to my window, but I found no way to change its
> caption. The Inspector only allows to change the color and alignment
> properties. Does this need to be changed programatically?

As "Title" do you mean a box? You may edit some properties in the
inspector, some other direclty by double-clicking the text in the window
(sometimes triple-click, the first needs to select the item)


> - I found no way to create connections between outlets by dragging
> like I do in Xcode. How is this done? (It may simply be that I don't
> have any connectable properties yet!)

Exactly like in InterfaceBuilder: ctrl-drag from source to target, then
int he inspector select the action or outlet. Beware that it needs to
exist. To do this you either need to load the class to parse the header
(you can quite safely reparse it) or add it manually with the correct
name. You you can create all outlets and generate the headers automatically.


> - Using @property for my controls had errors. Is this not supported in
> GNUStep? (It's OK, if it isn't, I don't have a problem with manually
> creating my properties).

that's obj-c 2.0 stuff. You need gcc 4.6 or clang.

You may want to check out the classic calculator tutorial by Pierr Yves
which was recently updated to current gnustep tools.

http://www.gnustep.org/experience/PierresDevTutorial/index.html


Riccardo

David Chisnall

unread,
Apr 9, 2011, 5:32:53 AM4/9/11
to Ivan Vučica, Omar Campos, discuss...@gnu.org
On 8 Apr 2011, at 22:24, Ivan Vučica wrote:

> Problem is in the compiler. I think GCC 4.6 introduced Objective-C 2.0 features. You can try using clang compiler, and you'd probably need to switch to libobjc2 runtime; I did not, but your mileage may vary. If you're under Debian (which, although it contains a deceptively named package "libobjc2", does not include the actual "libobjc2") I have a small blog post about this:


Not quite. GNUstep-base includes a compatibility framework that implements most of this stuff on top of the old GCC Objective-C runtime. All of the property-related stuff should work. The additional things you get from libobjc2 are:

- Property introspection (I think - clang emits this data for both ABIs, so we can probably add this if it's missing)

- Unique protocols (two protocols returned by @protocol() may give different sets of methods - this requires a little bit of help from the compiler, not sure if GCC 4.6 does it)

- Cacheable method lookup (requires support from your compiler's optimiser to be really useful - currently only implemented as LLVM optimisation passes, so only useable with clang and LanguageKit)

- Accelerated proxies (-forwardingTargetForSelector: is very cheap)

- Non-fragile ivars (requires a compiler that supports the new ABI, currently only clang)

- Type-checked method lookup (calls a handler when you call a method with the wrong signature, by default just logs a message in debug mode or does nothing in release mode, can throw an exception or generate a fixup method).

David

-- Sent from my Cray X1

Nicola Pero

unread,
Apr 9, 2011, 5:43:11 AM4/9/11
to David Chisnall, Omar Campos, discuss...@gnu.org

> - Unique protocols (two protocols returned by @protocol()
> may give different sets of methods - this requires a little
> bit of help from the compiler, not sure if GCC 4.6 does it)

Do you have an example/testcase of what you mean by this ?

Thanks


Ivan Vučica

unread,
Apr 9, 2011, 5:56:30 AM4/9/11
to David Chisnall, Omar Campos, discuss...@gnu.org
On Sat, Apr 9, 2011 at 11:32, David Chisnall <ther...@sucs.org> wrote:
On 8 Apr 2011, at 22:24, Ivan Vučica wrote:

> Problem is in the compiler. I think GCC 4.6 introduced Objective-C 2.0 features. You can try using clang compiler, and you'd probably need to switch to libobjc2 runtime; I did not, but your mileage may vary. If you're under Debian (which, although it contains a deceptively named package "libobjc2", does not include the actual "libobjc2") I have a small blog post about this:


Not quite.  GNUstep-base includes a compatibility framework that implements most of this stuff on top of the old GCC Objective-C runtime.  All of the property-related stuff should work.  The additional things you get from libobjc2 are:


This does not change the fact that older non-Apple GCC does not know about the syntax changes: @property, @synthesize, et al. Or am I wrong?

--
Ivan Vučica
iv...@vucica.net
Coming soon for iPhone, Zombie Ball - http://j.mp/zbivmail


Nicola Pero

unread,
Apr 9, 2011, 6:02:45 AM4/9/11
to Ivan Vučica, Omar Campos, discuss...@gnu.org

> This does not change the fact that older non-Apple GCC does not know about
> the syntax changes: @property, @synthesize, et al. Or am I wrong?

No, you are perfectly right. You need GCC 4.6, or clang, if you want
@property, @synthesize, etc. :-)

Thanks


David Chisnall

unread,
Apr 9, 2011, 6:05:08 AM4/9/11
to Ivan Vučica, Omar Campos, discuss...@gnu.org
On 9 Apr 2011, at 10:56, Ivan Vučica wrote:

> This does not change the fact that older non-Apple GCC does not know about the syntax changes: @property, @synthesize, et al. Or am I wrong?

Nope, although the problem here is that GORM's ad-hoc parser also doesn't know about them. Hopefully we can make GORM use libclang instead at some point soon, and then it can understand everything that the compiler can understand.

David

-- Sent from my PDP-11


David Chisnall

unread,
Apr 9, 2011, 6:08:18 AM4/9/11
to Nicola Pero, Omar Campos, discuss...@gnu.org


The runtime only sees protocols that are attached to classes. If you declare a protocol in a compilation unit and then reference it with @protocol(), the compiler will generate a reference to it, but the runtime won't see it. If you DON'T declare the protocol, but still reference it with @protocol(), then the runtime still won't see it, and the compiler will generate a stub protocol that only has the name filled in.

If the runtime sees the protocol, then it can add it to a table and update all other references to the protocol to use the same metadata (required / optional methods / properties). The GNUstep runtime does this, and I think the GCC 4.6 runtime does too.

To ensure that the runtime sees all protocols, I added a really ugly hack, where every protocol that is referenced but not attached to a class or category is implicitly added as a category on a class called __ObjC_Protocol_Holder_Ugly_Hack. This ensures that the runtime sees all protocols. The Apple solution to this is to make every protocol a public symbol with link-once ODR linkage (in definitions, external linkage in references) so you get a linker error if you reference a protocol that is declared, or declare it in two different ways. I'll probably do that at some point with the new ABI, but the ugly hack needs to stay for a bit for compatibility.

This is documented in README in libobjc2 svn.

David

-- Sent from my IBM 1620


0 new messages