RE: first steps
RE: first steps
- Subject: RE: first steps
- From: Ken Shmidheiser <email@hidden>
- Date: Mon, 6 Feb 2006 01:23:11 -0500
In this thread, Lars wrote:
I am bran new to cocoa and need to learn it from the command line (terminal
window), not using xcode by now.
I have compiled this little sample:
gcc -Wall -o test test.m -framework Cocoa ./test
#import <Cocoa/Cocoa.h>
int main( int argc, char *argv[] )
{
NSAutoreleasePool * pool = [ [ NSAutoreleasePool alloc ] init ];
NSApp = [ NSApplication sharedApplication ];
NSRunAlertPanel( @"Apple OSX", @"Hello world!",
@"OK",NULL,NULL);
[NSApp run];
[NSApp release];
[pool release];
return EXIT_SUCCESS;
}
but it creates a terminal window when I run it, and behind it there is the
alert window.
Is my code ok ? How to avoid the terminal window that shows when I run it ?
Lars,
Your code is fine, but you're not telling the OS how to handle the
compiled file.
Append the ".app" extension to the compiled file name to allow the
Finder to treat it as an application. Reminder: The ".app" extension
will be hidden from normal Finder view in the compiled file name.
Try compiling with the following from the Terminal command line:
gcc -Wall -o ~/Desktop/test.app ~/Desktop/test.m -framework Cocoa
This puts the file compiled application on the Desktop. If the
compiled file doesn't appear right way, move around another Desktop
icon to force a Finder refresh. (Out of habit, I compile all my code
to the Desktop. Anyone know a way of changing Xcode's default file
location?)
While Xcode's nib files are wonderful, there is still room for simple
apps compiled with raw text code right from the command line,
particularly in teaching situations. At least that's my opinion.
Let us know how you are progressing on your project.
Best,
Ken
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden