[Tutorial] Currency Converter [Part I of 2]

Discussion in 'iOS Development' started by allbrokeup, Oct 2, 2008.

  1. allbrokeup

    allbrokeup New Member

    Joined:
    Mar 7, 2008
    Messages:
    51
    Likes Received:
    0
    OK, today we will be using IB. So open up Xcode and go to New Project, iPhone OS, View-based Application or Window-based Application.

    First off, open up IB, drag one UIView onto the screen, make the color black.
    Click the UIView, go into the Identity Tab, where the Class Name is, type "MainView".

    Drag 3 UILabels, name the first "Amount in $:", Second "Rate:", Third "Converted:".
    Drag 3 UITextFields into the UIView, align the first with the first label and so on.
    Drag 1 UIButton into the UIView, name it "Convert"

    Click on the UIView, and go to the Tab in IB where you can add Actions and Outlets.
    Add 3 Outlets, the first one "dollarField", second "rateField", third "newAmount" ALL of type "UITextField". This is crucial. In Part II, I will include some code that on a "Open Rates in Safari" touch on a button will open "http://www.x-rates.com" in Safari and a UIAlertView with "About..." information.

    Add 1 Action, "convert:"

    Goto File > Write Class Files, and add them to your project in Xcode.

    After this, click the UIView (MainView), goto the Connections Tab, drag from "dollarField" to the First text field. Then, from the "rateField" to the Rate text field, then from the "newAmount" to the "Converted:" Text field. Then, click from the "convert:" action to the Convert Button and link it to "Touch Up Inside".

    Now, because I have added a UIView, and then the UITextFields and the UILabels in here, you can add this project to a Tab-Bar Application, a Toolbar-Application or any other type of iPhoneOS Application.

    Customize the UI a little bit. Because on Sunday, the code is coming from my personal project, my Mac has kicked the bucket temporarily and after I fix it, Part II of this tutorial will be here.
  2. Totally 1337

    Totally 1337 Active Member

    Joined:
    Mar 27, 2008
    Messages:
    3,966
    Likes Received:
    17
    Device:
    iPhone 4S (Black)
    nice! now i just need a mac

    Please Register or Log in to view images

  3. blackjak231

    blackjak231 Member

    Joined:
    Oct 1, 2007
    Messages:
    759
    Likes Received:
    6
    Device:
    iPhone 4 (White)
    ill try it out as soon as im on my mac! Thanks for sharing!
  4. Nickll9009

    Nickll9009 New Member

    Joined:
    Sep 19, 2007
    Messages:
    1,367
    Likes Received:
    8
    Device:
    iPod touch
    umm... why post this in the Toolchain section?
  5. jfb392

    jfb392 New Member

    Joined:
    Oct 20, 2007
    Messages:
    2,512
    Likes Received:
    21
    Device:
    iPod touch
    ..maybe because it's "Toolchain and SDK Development"?

Share This Page