Where do you code? (beginner)

Discussion in 'Public Game Developers Forum' started by WellSpentYouth, Jan 29, 2009.

  1. WellSpentYouth

    WellSpentYouth Well-Known Member

    Jan 11, 2009
    iPhone programmer
    App Tech Studios, USA
    Hello, I am in highschool and I am trying to start to code. It is extremely hard :p Please tell me where to code in Xcode! I have the sdk and I am trying to learn objective c. Thank you in advance. Any tips for a TOTAL beginner is WELCOME!!!!

    Side note: I posted a thread called "You play it but you don't like it" where I asked what games you played but didn't like. I had a few people including Superbad tell to get a life and stop posting spam. I am/was new to the site and if this site wants to grow, they should welcorm new members, not chase them away! BarringtonSoftware is cool btw.
  2. Schenk Studios

    Schenk Studios Well-Known Member

    #2 Schenk Studios, Jan 29, 2009
    Last edited: Jan 29, 2009
    Okay, you want a quick and dirty, here you go.

    Launch Xcode
    Close the startup window
    Go to File >> New Project
    Under iPhone OS select Application
    Select "View-Based Application"
    click Choose
    Name it, "Start" without the quotes

    This will open up the main Xcode windows. On the left hand side you'll have a panel titled "Groups & Files" with Start, Classes, Other Sources, Resources, Frameworks, and Products underneath.

    Click on the arrow next to Classes. This will expand that so you can now see StartAppDelegate.h, StartAppDelegate.m, StartViewController.h & .m

    Before we go any further, hit command + return to build and go the project. This should launch the simulator. It'll just be a grayish screen since we haven't done anything yet.

    Quit the simulator.

    Back in Xcode, in the left panel, click on resources arrow to expand that.

    Double click on StartViewController.xib. This will launch interface builder. You should see three panels => View, StartViewController.xib, and Library.

    Find a UILabel in the library and drag it over to the view. Now grab a Round Rect Button (UIButton) and drag it over to View. Grab another button and drag it over.

    Okay, to recap, you should have a label and 2 buttons placed on your view. Save it, and go back to Xcode. build and go again and you should see your label and buttons.

    You can click on your buttons but they don't do anything. Functionality to come if the mods allow it.
  3. hkiphone

    hkiphone Well-Known Member

    Oct 7, 2008
    Hi Shenk Studios.
    Thats a really useful starter to how it all works. I was hoping to mess around with iPhone development when I get an Intel Mac (still only have a G4 Mac Mini....) and was getting really curious how it all works.
    Much appreciated!
  4. Schenk Studios

    Schenk Studios Well-Known Member

    Part II

    To recap, in the first part we learned how to launch Xcode, create a new project, navigate through the different parts of Xcode, launch Interface Builder, and add labels and buttons to our view.

    Now to add some functionality to our Start app.

    If you haven't done so already, launch Xcode, open up recent projects and select Start. Now in StartViewController.h we will want to add the following line below @interface

    IBOutlet UILabel *myLabel;

    and below }

    @property(nonatomic, retain) IBOutlet UILabel* myLabel;

    - (IBAction)buttonOneClicked;
    - (IBAction)buttonTwoClick;

    Basically what we've done here is let Interface Builder know that we are going to programatically do things with myLabel and some buttons. Hence the IB prefix.

    Now, in Xcode switch over to StartViewController.m, (the implementation file). Below where it says @implementation... write in

    @synthesize myLabel;

    Build and go, Nothing should have changed yet, but we're about to make the connections we need. Quit the simulator and go back to Interface Builder by double clicking on StartViewController.xib within the Resources.

    Now the next part can be kind of tricky, so take it slowly, and follow the steps precisely.

    Step 1: Highlight "File's Owner"
    Once it's highlighted, control click on it so that you see a blue connector line and drag that line over to your label. Once it highlights the label, release and there should be a popup window that says Outlets, myLabel, view. Select myLabel.

    Step 2: Highlight one of your buttons within your view. When it is shaded in beige, and has the resizing corners you've selected it properly. Now control click on it and drag the blue connector over to File's Owner. Release and select buttonOneClicked.

    Step 3: Do the same for the other button, just select buttonTwoClicked

    Save and quit Interface Builder, we're done with it.

    Back in Xcode it's time to add the last part to finish this program up.

    In StartViewController.m we need to write two methods to control our button s functionality. We've already supplied the method signature in the header file (.h) So either copy and paste those sigs or rewrite them as follows. (Note) these methods should go after the @synthesize myLabel;

    - (IBAction)buttonOneClicked{
    myLabel.text = @"Your Text Here";

    - (IBAction)buttonTwoClicked{
    myLabel.text = @"Some Different Text Here";

    Save, build and go. Now you can click on your buttons and they do stuff!
  5. WellSpentYouth

    WellSpentYouth Well-Known Member

    Jan 11, 2009
    iPhone programmer
    App Tech Studios, USA
    help again

    hey, thanks for all the input! I don't have interface biulder!! please help!
  6. I am learning myself, and found a good podcast called Hot Cocoa in iTunes here. Episode No 7 will be of particular interest to you, as he goes through an example app for the iPhone and goes through it step by step.
  7. currymutton

    currymutton Well-Known Member

    Oct 16, 2008
    Thanks for the tips. I am a new learner too.

    I am using a cheap old iBook G4 (1GHz with 768MB RAM) and, apart from a little extra in installing the iPhone SDK, it runs very smooth and I can run the emulator and debug. At least it is much faster than running on VMWare (3GHz C2D with 4GB RAM).
  8. currymutton

    currymutton Well-Known Member

    Oct 16, 2008
    Looks like the Podcast is not available here in my place. :( Would you mind posting us another ink, please?
  9. These are the only links I can give for it- the standard definition version here, and the HD version here. If it's not available in your country, then I don't think there's another way of you getting them unfortunately.

Share This Page