Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

hrach

macrumors newbie
Original poster
Mar 19, 2011
10
0
Discussion about Objective-C programming language

Hello guys,

I have installed gnustep on my PC (OS: Windows).
The GUI application is compiled successfully but when I executed the created application nothing is done (application is not shown and there is no any error).

Below are coming my GNUmakefile and source file (MyApp.m)

MyApp.m

Code:
#include <Foundation/Foundation.h>
#include <AppKit/AppKit.h>

@interface MyDelegate : NSObject
- (void) printHello: (id)sender;
- (void) applicationWillFinishLaunching: (NSNotification *)not;
@end

@implementation MyDelegate : NSObject 
- (void) printHello: (id)sender
{
  printf ("Hello!\n");
}

- (void) applicationWillFinishLaunching: (NSNotification *)not
{
  NSMenu *menu;
  NSMenu *infoMenu;
  NSMenuItem *menuItem;

  menu = AUTORELEASE ([NSMenu new]);

  infoMenu = AUTORELEASE ([NSMenu new]);

  [infoMenu addItemWithTitle: @"Info Panel..." 
            action: @selector (orderFrontStandardInfoPanel:) 
            keyEquivalent: @""];

  [infoMenu addItemWithTitle: @"Help..." 
            action: @selector (orderFrontHelpPanel:)
            keyEquivalent: @"?"];

  menuItem = [menu addItemWithTitle: @"Info..." 
                   action: NULL 
                   keyEquivalent: @""];

  [menu setSubmenu: infoMenu  forItem: menuItem];

  [menu addItemWithTitle: @"Print Hello"  
        action: @selector (printHello:)  
        keyEquivalent: @""];

  [menu addItemWithTitle: @"Quit"  
        action: @selector (terminate:)  
        keyEquivalent: @"q"];

  [NSApp setMainMenu: menu];
}
@end

int main (int argc, const char **argv)
{ 
  [NSApplication sharedApplication];
  [NSApp setDelegate: [MyDelegate new]];

  return NSApplicationMain (argc, argv);
}

GNUmakefile:

Code:
include $(GNUSTEP_MAKEFILES)/common.make

APP_NAME = MyFirstApp
MyFirstApp_OBJC_FILES = MyApp.m 

# Uncomment the following if you have an icon
#MyFirstApp_APPLICATION_ICON = MyApp.png
#MyFirstApp_RESOURCE_FILES = MyApp.png

include $(GNUSTEP_MAKEFILES)/application.make

Execute application:
openapp MyFirstApp.app


Note:

I have download and install Gorm. It works correctly and shows GUI application.


Thanks in advance for any helps.
 
Last edited by a moderator:
I have installed gnustep on my PC (OS: Windows).
The GUI application is compiled successfully but when I executed the created application nothing is done (application is not shown and there is no any error).

Please use CODE tags (the hash mark in the editor) around code and output.

Are you following some sort of guide? If so, please link to it.

What did you expect to happen?

B
 
You can use:

Code:
printf("Program working \n");

to get comments on the console. This is the first step to see what is working.
 
Thanks for your response.

I expected to see window.

When I have added printf in the main function there was no output on the console.
After commenting all function in the source except printf in main function and updating make file the string has been printed on console.


APP_NAME = MyFirstApp -> TOOL_NAME = MyFirstApp
include $(GNUSTEP_MAKEFILES)/application.make -> include $(GNUSTEP_MAKEFILES)/tool.make


I have no experience to develop GUI application using Objective-C.
Could you please send me some example of GUI application (only simple window creation).
 
Last edited:
Also I have learnt about second desktop. Maybe the window opens in not current window and I will change it but I am not sure about it and I don't know how do it.

I appreciate any advice.
Thanks!
 
I will ask again.

What resources are you using to follow along and learn Objective C in your environment? Please be specific.

You may want to step back and learn the language first without the UI, build some console based apps using GNUStep's Foundation class http://wiki.gnustep.org/index.php/Foundation and then start worrying about the GUI.

Note also that doing it on GNUStep/Windows will always be somewhat different than on a Mac or iOS.

EDIT:
Why do you expect to see a window? You have not created one or loaded a nib with one (at least anywhere I can see).

That's exactly why I asked what the OP expected to happen. I too don't see any reason that code would be expected to create a window, but I really don't know how GNUstep handles things on Windows with the lack of a system wide menu bar, etc...

B
 
That's exactly why I asked what the OP expected to happen. I too don't see any reason that code would be expected to create a window, but I really don't know how GNUstep handles things on Windows with the lack of a system wide menu bar, etc...

GWorkspace provides the system-wide menu bar ;)
 
I know C++.
I want to learn Objective-C.
I have install Leopard 10.5.2 on my PC successfully but I haven't manage to install and run Snow Leopard 10.6.3. The installation is OK but when I have run the OS it is hang.
After I decided to use gnustep under Windows. And I want to sure that I can execute GUI application via gnustep.

Note: I know Objective-C a little and I should learn much so to improve my skills.

Thanks for your help and quick response. It is a GOOD forum with the GOOD members.
 
To tell the truth I don't know what Gworkspace is. I will try to take a look at it.
I have installed Gworkspace under Gnustep successfully.
 
Last edited:
I've had a quick look at those tutorials. You won't get a window (ignoring the system provided Info/About this app one) until you get onto the second tutorial "First Steps in GNUstep GUI Programming (2): NSWindow, NSButton".

My suggestion is to keep working. Don't move on from one page until you understand it fully. This means you should understand each and every line of code: you should have known that there were no windows in the tutorial you linked to: don't move on until you understand why. That way by the time you complete the tutorial series you'll actually know something.
 
I know C++.
I want to learn Objective-C.

It would help to know your motivation to learn Objective-C. Do you plan on ultimately creating apps for the iOS App Store and Mac App Store or is this just a personal enrichment thing?

There's nothing inherently wrong with the GNUStep tutorials you found, but IMHO you want to step back a bit and not worry about the GUI bits yet until you are on the platform you want to develop for. (Which I doubt is GNUStep on Windows).

This may be a useful resource for you to read over. http://www.chachatelier.fr/programmation/objective-c.php

B
 
I've had a quick look at those tutorials. You won't get a window (ignoring the system provided Info/About this app one) until you get onto the second tutorial "First Steps in GNUstep GUI Programming (2): NSWindow, NSButton".

My suggestion is to keep working. Don't move on from one page until you understand it fully. This means you should understand each and every line of code: you should have known that there were no windows in the tutorial you linked to: don't move on until you understand why. That way by the time you complete the tutorial series you'll actually know something.

Thanks. I'll continue to take a look at this link taking into account your advice.
 
It would help to know your motivation to learn Objective-C. Do you plan on ultimately creating apps for the iOS App Store and Mac App Store or is this just a personal enrichment thing?

There's nothing inherently wrong with the GNUStep tutorials you found, but IMHO you want to step back a bit and not worry about the GUI bits yet until you are on the platform you want to develop for. (Which I doubt is GNUStep on Windows).

This may be a useful resource for you to read over. http://www.chachatelier.fr/programmation/objective-c.php

B

Thank you for your help.
 
Thanks a lot!
I have managed to create a simple window with your help.
Now I come back and start to learn Objective-C at first as I know that I can also develop GUI application using Gnustep.

Sincerely,
Hrach
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.