Tuesday, July 6, 2010

Introduction to Xcode - Easy Loan Calculator Part 1

Ok. Finally, let's get down to writing some decent code. Let's skip the HelloWorld example and code something that perhaps we can probably get some hits in appstore. See below for the finished product.
Its a loan calculator, where you fill in the loan amount, the interest rate, and the no. of years of the loan.
The app then calculates the monthly payment that you ought to pay, calculates the total interest paid throughout the loan and the total amount paid.


First off, open xcode and create a View based project.
Name it EasyLoanCalculator.

You should see the above screen.
Left pane: shows all your files in a similar fashion to your solution explorer in Visual Studio (VS).
Right pane shows the individual files selected in the folder and the code in the lower right.

You have a couple of folders. More important ones for now are the 'classes' folder and the 'resources' folder. The classes folder basically contains your source code files. Resources folder contains your UI files, i.e. Forms in VS.

For this first app, you just to write code in EasyLoanCalculatorViewController.h and EasyLoanCalculatorViewController.m. The .h file is the header file where you write all your declarations. Including declarations for UI Controls like labels, textboxes. The .m file is where all code is.

In 'resources', you see EasyLoanCalculatorViewController.xlb which is your Interface Builder file. You know, the one where you drag and drop UI controls in like for forms in VS. Click on it and Interface Builder (think VS only in design view) opens with a blank iPhone screen.

That's all for introductions and orientations. Await part 2 for actual programming.

1 comment:

  1. I have found that this site is very informative, interesting and very well written. keep up the nice high quality writing

    Michael Phillips Attorney

    ReplyDelete