Latest

Powered by Blogger.

Creating your first Application for Iphone – Tutorial



Creating your first IOS App in Mac OSX is very simple and easy. You need to grab on few things before getting started.


Pre-requisites

 ____________________________________________  

1) Mac OS X , Latest version is recommended. ( In my case I have snow leopard 10.6.8)
2) Xcode and IOS SDK , Latest version is recommended.( In my case I have  xcode_3.2.5_and_ios_sdk_4.2 SDK)
Note  : Before starting you must have installed Xcode and IOS SDK in MAC. Installing Xcode and IOS SDK is very simple , just grab on their “.dmg” file in my case i have  xcode_3.2.5_and_ios_sdk_4.2.dmg , just double click on it and it will automatically begin to install it in your MAC operating system by following the onscreen instructions.
After grabbing above tools you are now ready to get your hands dirty with your first ios application. In this application we will build a simple ‘Hello World’ Application , so lets get started…

Steps for Evaluation

________________________________________


Step 1 : After installing Xcode , launch it in your MAC. And you will face the following scenario.

________________________________________

Untitled

________________________________________

Step 2 : Click on “Create a new Xcode Project” on the left top side.
Step 3:  Now you will be confronted with this scenario

________________________________________

2

________________________________________


Step 3: Select the “View Based” Application from options above in the screenshot.
Note : I am not gonna discuss , what those 7 options mean? , what do they do? , if you want to know about them , then stay tuned to “BaidarTuts” , I will soon make tutorials regarding them.
Step 4 : After selecting “View Based” Application click on “Choose” Button and you will be prompted for providing a name to the application , give any name you want , I have given “Hello world” name to my application.
Step 5: Now you will be confronted with the following scenario as show in below snapshot

________________________________________


3

________________________________________


Step 6 : Click on the “Classes” folder on the left panel as show in below screenshot.

________________________________________


4

________________________________________


Explanation Scenario :     There are 4 files , Skip the first two files and concentrate on the bottom two files in the “Classes” folder.

1) helloworldViewController.h File :

It is the header file or interface file , Interface file is used to provide us the structure of our program but not the real implementation, it contain the structure of methods but not its body.

2) helloworldViewController.m File :

It is implementation file , where the implementation of our actual program is written. Which mean the body of the methods defined in the interfaces. And as well as the body of the structural interfaces.
Step 7 : Now click on “Resources” folder in the left panel and select “helloworldViewController.xib” file.

Explanation Scenario :

helloworldViewController.xib File :

It is the Design Interface , where we design the look of our app, that how would it appear in Iphone or Ipad. We do things like drag and drop stuff here.
Step 8 : After clicking on “helloworldViewController.xib” file , a new Interface Builder will get open and would give you the following scenario

________________________________________



5

_______________________________________


Explanation Scenario : There are 4 things you need to know about which are explained below

1) Library ( The first one marked with rectangle from left side ) : Library is a repository of different tools you gonna need to build your interface , like TextBox and buttons etc.
2) helloworldViewController.xib (Second one from left side) : This is the important file , which is used to link your design interface with your real time coding interface.
3) View (Third one from left side) : This is the place where you gonna drag and drop things and that would be appeared on your iPhone or iPad screen.
4) View Attributes (Fourth one from left side) : It is used to change the specifications of your “View” like changing the background color or changing the orientation from portrait to landscape etc.
Step 9 : Now grab a Round Rect Button from the “Library” and drag it to the “View” as shown

________________________________________


8

________________________________________



Step 10 : Now its time to get your hands dirty with some IOS coding. so click on the helloworldViewController.h file under Classes folder and open it. And add the following code

Code

________________________________________

#import <UIKit/UIKit.h>

@interface helloworldViewController : UIViewController {

UIButton *show;
}
@property (nonatomic, retain) IBOutlet UIButton *show;
- (IBAction)showalert;

@end

________________________________________


Step 11 : Now open “helloworldViewController.m” file and paste the following code after “@implementation helloworldViewController”

Code

________________________________________


@synthesize show;

________________________________________


and the following code before “@end” line

________________________________________


Code

________________________________________


- (IBAction)show
{
UIAlertView *alertHello = [[UIAlertView alloc]
initWithTitle:@"MyFirstEverIOSApp" message:@"Hello, World!" delegate:nil cancelButtonTitle:@"Done" otherButtonTitles:nil];

// Show helloWorld Message
[alertHello show];
}

________________________________________


7

________________________________________


Step 12 : Now link your “Round Rect Button” with your code that we have written in step 10 and 11. Right click on the “round rect button” and hold your right click and drag it to the “file owner” and release the hold on your right click of mouse. Now select “show alert” and you round rect button would be hooked to your “show alert” method.

________________________________________


9
10

________________________________________


Step 13 : Now test your application in iphone or ipad by click on this button in Xcode :    11

Step 14: Here is your hello world application in Iphone simulator. Now click on the button and “Alert” message will be pop up to you.

________________________________________

HelloWorld-App

________________________________________


Reference : You can find the same content at my other blog : http://baidartuts.altervista.org/creating-your-first-ios-app-in-mac-osx-tutorial

________________________________________

Newer Post
Previous
This is the last post.
  • Blogger Comments
  • Facebook Comments
Item Reviewed: Creating your first Application for Iphone – Tutorial Description: Rating: 5 Reviewed By: Unknown
Scroll to Top