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

Me1000

macrumors 68000
Original poster
Jul 15, 2006
1,794
4
ok, I am beginning (and I mean beginning) objective-C development. I am currently a PHP developer... but that is beside the point.

Here is my problem! HOW DO I COMPILE?

here is my simple hello world app..

this is for the file main.m
Code:
#import <stdio.h>

int main (int argc, const char *argv[]) 
{ 
	printf ("Hello World!\n"); 
	return 0; 
}

right, so shouldnt I be able to hit this button?
picture2az8.png

and it bring up a terminal window that says "Hello World!"

Am I missing something? I mean I was able to compile it from the terminal and run it with no problem, so im guessing this is just an Xcode thing im not understanding.

Anyway can someone please help me?

Thanks
 

Me1000

macrumors 68000
Original poster
Jul 15, 2006
1,794
4
ah,

Thank you...

Is there any way I can make this show up as a pop up window and stay open until I close it every time I compile the code?
 

tacoman667

macrumors regular
Mar 27, 2008
143
0
First off that isn't even objective-c. That is C proper. Objective C would have you sending a NSLog(@"Hello World!") message but this would show in the console for XCode. Check out the Apple Developer Center for some samples.

As for C, I haven't used that in XCode yet but that looks right to me. You may not have the console running when the application builds and runs. Go into the XCode preferences menu and look for the build tab, I think, and you should see some dropdowns for selecting what happens on successful run. That is how I got my console window to display when I run my iPhone code now.
 

Me1000

macrumors 68000
Original poster
Jul 15, 2006
1,794
4
Alright,
here is what I did for future reference to anyone else...

under the general tab in prefs. change it from all-in-one to default.
Then you can bring up the console that way... before it was just in a nasty one window view that made it hard (for me) to work with...
 

tacoman667

macrumors regular
Mar 27, 2008
143
0
Time to be a jerk, I guess, but any C is Objective-C, as Objective-C is a proper superset of C. You have to start somewhere.

-Lee

I hope you are just tired as I was not trying to imply aggression in my statement. The OP simply stated that they were starting Objective-C with a PHP background and I was merely stating that that was C and not Obj-C.

Obj-C is backwards compatible to C proper but the 2.0 language version is much more picky when it comes to C syntax.


-Me1000:

Sweet. I didn't know about that. Mine never did that and it's always been in "default" mode. I had to go into a different setting which I cannot remember right now. Phew I'm tired. :)
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
*Now* I'm tired, but I should clarify that I was being pedantic and tried to indicate it in my post. I know you weren't being aggressive, and using NSString literals instead of char * literals is definitely a better start.

I was just being picky, and unless things changed more in 2.0 than I know objC is still a proper superset. I will admit that what I've read is mostly about GC and fast enumeration, so I could be wrong.

-Lee
 

Darkroom

Guest
Dec 15, 2006
2,445
0
Montréal, Canada
ah,

Thank you...

Is there any way I can make this show up as a pop up window and stay open until I close it every time I compile the code?

yes:

Preferences > Debugging > On Start: Show Console.

it's also a good idea to have the Console clear automatically after each build:

Preferences > General > Environment: Automatically clear log
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.