PDA

View Full Version : Probably just me getting used to Xcode...




Me1000
Jun 11, 2008, 10:24 PM
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
#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?
http://img508.imageshack.us/img508/9998/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



sord
Jun 11, 2008, 10:33 PM
Click Run -> Console

Me1000
Jun 11, 2008, 10:35 PM
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
Jun 11, 2008, 10:40 PM
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
Jun 11, 2008, 10:52 PM
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...

lee1210
Jun 11, 2008, 10:58 PM
First off that isn't even objective-c. That is C proper.


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

tacoman667
Jun 11, 2008, 11:37 PM
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
Jun 12, 2008, 12:32 AM
*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
Jun 12, 2008, 12:34 AM
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