BYTE -- Instead of the typical Hello World example, here's a first iPhone app to build that actually does something useful.
Your first app ever will calculate how much tip you should give your restaurant server.
Just type in price of the meal, the percentage you want to tip, and tap calculate to get the result. A cool app you’ll usually actually use. It's easier than you think to build your first iOS app. Yours will end up looking like this.
For this project, you need to have an Intel-based Mac running Mac OS X 10.6 Snow Leopard and Xcode 4 installed. Download Xcode 4 from the Apple Developer website if you're a registered developer or buy it directly from Apple’s App Store.
First, Launch Xcode and create a new New Project by selecting File / New / New Project from the menu. This presents you with project templates you can use as your starting point. Select the iOS Application/ View-based Application template and click Next.
Now specify the name of your new application. Type in: TipCalculator for the product name, change the company identifier to your name, keep the device family set to iPhone, and deselect Include Unit Tests as we will not be covering that functionality.
To continue, click Next.
Find a suitable location to save your new project and then click Create. The TipCalculator project will generate -- and Xcode’s main interface will display summary information about the application target. Change the Deployment Target to 3.0. That will allow the app to run on older versions of iOS (3.0 or higher). Also, change the supported orientations so Portrait is the only selection.
Expand the folders in the navigator area located on the left side of Xcode. Then, select the TipCalculatorViewController.xib file.
This will open the primary user interface file (nib file) with the Interface Builder editor. Make sure the view selector in the toolbar is showing the Utility area, which gets displayed on the right side of the Xcode window.
Drag over a Label from the Objects library and drop it into our view near the top.
Select the label and make sure the Attributes inspector is displayed in the Utility area. Change the Text from Label to Tip Calculator. Expand the height and width of the label by clicking on one of the corner circles and dragging to resize. The label should cover most of the width of the view.
Make sure the Text Alignment is centered and that the label is also in the center of the screen. Then, click on the Font button, which will bring up the Fonts dialog box. Change the size to 48. Adjust the size of the label again to accommodate font width and height if you like. If the label width or height is too small then the font size will adjust to fit.
Drag out a couple more labels to display Meal Price and Tip Percent.
Building A Mobile Business MindsetAmong 688 respondents, 46% have deployed mobile apps, with an additional 24% planning to in the next year. Soon all apps will look like mobile apps – and it's past time for those with no plans to get cracking.
InformationWeek Must Reads Oct. 21, 2014InformationWeek's new Must Reads is a compendium of our best recent coverage of digital strategy. Learn why you should learn to embrace DevOps, how to avoid roadblocks for digital projects, what the five steps to API management are, and more.