PDA

View Full Version : Help an XCode newbie!




designbot
Aug 3, 2007, 10:44 PM
I'm learning to program using Stephen G. Kochan's book, Programming in Objective-C. I don't like terminal-based text editors like vi, so I'm using XCode to write & compile my programs. So far so good.

As I go through the book, I will be writing many very small programs. Do I need to create a whole new project in XCode for each one, with a separate folder and everything? Does each code file need to be named "main.m"? I'm sure there's a better way. I'd like to have a folder on my hard drive for each chapter, with a separate file saved for each exercise, something like "exercise2.1.m". Is this possible?

I also have TextMate, so if there's a simple way to accomplish the same thing with that, and easily compile the programs using gcc or something, that would be fine too.

If this is a stupid question, go easy on me; I'm new to this Objective-C stuff. :)



mduser63
Aug 4, 2007, 12:26 AM
Too tired to post a detailed reply right now, but here are the basics. You don't strictly need to create a new project for each program, but it's easier that way, trust me. Even when not using XCode, I always have a separate folder for each project/program I'm writing. For the simple programs in Kochan's book (single source files IIRC) XCode is probably overkill anyway. TextMate does have the ability to compile source code you're editing, but I've not used that feature much, so all I can say is you need to read the help and figure it out. When you move on to Cocoa, you'll have many source files in the same project/program and XCode's project management features become very helpful, so learning XCode now is probably not a bad idea.

Good luck, and enjoy learning to write software on the Mac. I've been learning for about 2 years now, and while I have an app that's out there with lots of people using it, I still enjoy learning new Cocoa stuff all the time.

Littleodie914
Aug 4, 2007, 08:59 AM
I would create separate projects, if I were you.

That's the easiest way to do it, for example, create a folder called "My Cocoa Programs," and save all of your projects in that folder. For example:

My Cocoa Programs -> Exercise 2.1 -> Exercise21.xcodeproj

My Cocoa Programs -> Exercise 3.6 -> Exercise36.xcodeproj

And yes, for many terminally-ran tools, you will begin by executing code in the main.m file. Think of it as the "index.html" of code files. When you get into developing GUI apps, you don't modify the main.m, since it will just start your other code files running. :)

designbot
Aug 4, 2007, 11:10 AM
OK, guess I'll just make new projects for each one then.

I tried compiling from TextMate, but it just uses XCode to compile, so it works basically the same.

Thanks, everybody!

DHagan4755
Aug 4, 2007, 07:40 PM
Just out of curiosity, what types of applications are you guys interested in writing (you don't have to give away ideas, just in general)?

mduser63
Aug 4, 2007, 11:47 PM
Just out of curiosity, what types of applications are you guys interested in writing (you don't have to give away ideas, just in general)?

I like to wrrite stuff that I see a use for myself. If it's helpful to other people, fine, but I think it's best to write something that you'll actually use. And you should certainly use anything you write.

Soulstorm
Aug 5, 2007, 03:59 AM
Just out of curiosity, what types of applications are you guys interested in writing (you don't have to give away ideas, just in general)?

Anything that would prove useful for my programming experience. I recently made a Launcher for FS2_Open, which ended up being noticed by the developers of the port. But I have made many things, that although they may never see the light of day, they were absolutely necessary to make, since I have learnt a lot of things by making them.

Example: I have made a framework, which grew big over the time, and became a library which is used by my colleagues and friends of mine (and me, of course) to make programs easier to make. This library includes basic parsers, string actions, templates for maps for game creation, and much more. I am now trying to make a very basic chat application. The internet is filled with applications of this kind, but the knowledge I will gain in the process will be invaluable.

I recommend you do something similar. In order to become a good programmer, you need knowledge that will be gained by making useless programs. In order to become great programmer... well, you need to become a good programmer first. :)

janey
Aug 5, 2007, 04:08 AM
Just out of curiosity, what types of applications are you guys interested in writing (you don't have to give away ideas, just in general)?

Like the people above me, stuff I need/want. Usually as a replacement for some awful software or something where there exists no application to do it.

Right now I'm working on a menubar item that keeps track of a certain something for me...the original app is awful and unusable for long periods of time (which is what it's supposed to do...), and I don't use Dashboard, which would have been the easier way out. I'm having an insane amount of trouble though, because there are a TON of ways to manage the item in question and I can't account for all of them, nor can I think of a good way to do so :(