IT tutorials
 
Mobile
 

iPhone SDK 3 : SDK and IDE Basics

12/25/2012 11:38:14 AM
- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

In this section, we walk you through the process of creating your first iPhone application. But first, you need to obtain the iPhone SDK and install it on your Mac.

1. Obtaining and installing the SDK

Obtaining and installing the iPhone SDK is easy; just follow these steps:

  1. Get your iPhone developer Apple ID and password from: http://developer.apple.com/iphone/

  2. Download the latest iPhone SDK for iPhone OS from the site mentioned above.

  3. Install the iPhone SDK on your Intel-based Mac.

Now, you're ready to create your first project – read on!

2. Creating a project

Locate XCode and launch it. You can use Spotlight to find it or you can navigate to /Developer/Applications/XCode. XCode is the central application for writing, designing, debugging, and deploying your iPhone applications. You will use it a lot, so go ahead and add it to the Dock.

From XCode, select File->New Project. You should see a window, similar to the one shown in Figure 1, asking you for the type of project you want to create. Choose the default and create a window-based application. This is the most generic type of iPhone project and the one that can be customized for different needs.

Figure 1. Choosing window-based application in the project creation process.

Click on Choose... and enter the name of your project (here, we're using My Project) and hit Save. A new directory is created with the name you entered, and several files are generated for you. You should now see the newly created iPhone project as in Figure 2.

Figure 2. A newly created iPhone project in XCode.

3. Familiarizing yourself with the IDE

As you can see from Figure 2, the main window is divided into several areas. On the top, you will find the Toolbar (Figure 3). The Toolbar provides quick access to common tasks. It is fully configurable; you can add and remove tasks as you want. To customize the Toolbar, Control-click it and choose Customize Toolbar.... There, you can drag your favorite task on the Toolbar. Hit Done when you're finished. To remove an item, Control-click on it and choose Remove Item.

Figure 3. The XCode Toolbar.

On the left-hand side, you'll see the Groups & Files list (Figure 4).

Figure 4. The Groups & Files list in XCode.

This list is used to organize the source code, frameworks, libraries, executables, and other types of files in your project.

The list shows several files and groups. Groups can contain other groups and files. You can delete a group as well as create a new one. The group indicated by the blue icon whose name is the same as the name you've chosen as the project name is a static group. Underneath it, you see all your headers, implementations, resources (images, audio files, etc.), and other related files. The folder-like yellow groups act conceptually as containers. You can have containers inside other containers and all files inside these containers live in the same directory on the disk. The hierarchy only helps you organize things. You have full freedom to organize your project's layout as you like. The compiler will pick up the resources, headers, and implementation files when it builds your application.

The other kind of groups that are listed below the project group are called smart groups. There are two types of smart groups: 1) built-in smart groups, and 2) custom smart groups. The content of the built-in smart groups cannot be customized. Examples of these groups include executables, bookmarks, errors/warnings, and targets. Customized smart groups are shown in purple, and two predefined groups are created for you when you create a new project.

Figure 5. The Details view with the text editor view.

Figure 5 shows the Details view and the text editor beneath it.

Selecting an item in the Groups & Files list will result in its details being shown in the Details view. You can go to a full-editor window using Command-shift-E.

4. Looking closely at the generated code

Expand the Classes and Other Sources groups. You will notice several files that live underneath these two groups. Click on the main.m file and expand to a full-editor view.

The main.m file looks very similar to a C file with a main() function. All that main() does is prepare for memory management and launch the application.

Click on the My_ProjectAppDelegate.h file under the Classes group. You will notice that the editor changes its content. This file contains the declaration of the application delegate class. Every application that runs on the iPhone OS has a delegate object that handles critical phases of its lifecycle.

Click on My_ProjectAppDelegate.m. This file with the .m extension is the counterpart of the previous .h file. In it, you see the actual implementation of the application delegate class. Two methods of this class are already implemented for you. The applicationDidFinishLaunching: method is one of those methods that handles a particular phase of the application lifecycle. The other method, dealloc, is a method where memory used by this object is released. In iPhone OS, you manage the allocation and freeing of memory as there is no garbage collection. Memory management is crucial in iPhone development, and mastering it is very important.

The generated files and resources are adequate for starting the application. To launch the application, click on Build and Go in the Toolbar or press the Command-Enter key combination. You'll notice that the application starts in the Simulator and it only shows a white screen with the status bar on top. Not very useful, but it works!
 
Others
 
- Bluetooth on the iPad : Pairing with a Bluetooth Device
- Personalize & Secure Your iPad : How to Secure Your iPad with a Passcode
- Windows Phone 8 : XAML Overview - What Is XAML?
- Windows Phone 8 : Writing Your First Phone Application - Working with the Phone
- Setting Up Your Android Development Environment : Hello, Android
- Setting Up Your Android Development Environment : Setting Up Your Development Environment
- Symbian OS : Error-Handling Strategies - Escalate Errors
- Symbian OS : Error-Handling Strategies - Fail Fast
- BlackBerry Tablet Applications : Exploring the APIs - GPS
- BlackBerry Tablet Applications : Exploring the APIs - Accelerometer
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
Technology FAQ
- Is possible to just to use a wireless router to extend wireless access to wireless access points?
- Ruby - Insert Struct to MySql
- how to find my Symantec pcAnywhere serial number
- About direct X / Open GL issue
- How to determine eclipse version?
- What SAN cert Exchange 2010 for UM, OA?
- How do I populate a SQL Express table from Excel file?
- code for express check out with Paypal.
- Problem with Templated User Control
- ShellExecute SW_HIDE
programming4us programming4us