Talk:Hello world/Graphical

Revision as of 18:59, 9 December 2008 by rosettacode>ShinTakezou (obj-c)

Graphical console?

What is a graphical console? I thought a console is always text mode.
It seems that, again, there are many interpretations of what the task means, because of the vague task specification.
--PauliKL 09:31, 27 October 2008 (UTC)

I changed the description. Is that more clear? --Mwn3d 17:00, 27 October 2008 (UTC)
I guess. But since there are multiple different ways to output the message, I think it should be mentioned in each implementation, where and how the message will appear. --PauliKL 09:19, 28 October 2008 (UTC)

Objective-C

This is the second fragment of Obj-C code that I try to run without success!! :) First, it is not a complete example (copy-pasting and simply compiling won't work...). Ok, I could try to complete the code... I obtained

#import <AppKit/AppKit.h>

int main()
{
NSAlert *alert = [[[NSAlert alloc] init] autorelease];
[alert setMessageText: @"Goodbye, World!"];
[alert runModal];
}

After "several" effort about understanding a NXConstantString vs NSConstantString problem, I succeeded compiling it with

gcc -lobjc -fconstant-string-class=NSConstantString  _box.m -lgnustep-gui -lgnustep-base -o box

but running it, I obtain:

2008-12-09 15:39:11.749 box[9570] autorelease called without pool for object (80cf8c0) of class NSAlert in thread <NSThread: 0x8081690>
Segmentation fault

Ok this is not a place for debugging or what, but shouldn't the given codes work properly?! It seems not to work. --ShinTakezou 14:42, 9 December 2008 (UTC)

I'm guessing that most of the Objective-C samples were written by a Mac OS X/Cocoa developer, since they are the prime users of Objective-C. Perhaps you could prefix the non-working-with-GNUStep examples with the {works with|Cocoa} template? --IanOsgood 17:45, 9 December 2008 (UTC)
Don't know really... I've also a Cocoa/Cocoa.h header, which is just an inclusion of Foundation/Foundation.h and AppKit/AppKit.h, with some more thing... the header stating "Cocoa compatible declarations". So hopely I should be able to do my Cocoa programming under GNU/Linux :D ... The fact is that this example uses just basic language things, and NSAlert, which exist in GNUstep framework, and I believed that such a code should compile and run on my platform. I succeeded compiling, ... if I change the code this way:
#import <AppKit/AppKit.h>

int main()
{
NSAlert *alert = [[NSAlert alloc] init];
[alert setMessageText: @"Goodbye, World!"];
[alert runModal];
[alert release];
}
the "autorelease called without pool" error is not risen... but a great segmentation fault is the only thing I obtain anyway :(. I need to take a deeper tour on Obj-C on the web; I want it working :) --ShinTakezou 18:59, 9 December 2008 (UTC)
Return to "Hello world/Graphical" page.