If you have MAC system and preloaded with MAC operating system like OS Lion, OS snow Leopard, then good other wise Download Hackintosh(here you can get about Hackintosh installation ) for windows based system.
Download Xcode SDK(Software Development Kit)and install it in MAC OS. Now you are able to develop iphone first Hello World app.Don't forget to activate command key, for activating command key:
go>> to system preferences >> click keyboad >> clickmodified keys>> replace control button as command and command button as control just finish.
Open Xcode
create new project and select View-Based Application
Now let's check out the implementation of the delegate, HelloWorldAppDelegate.m. There are several messages we can get from the UIApplication object, however the template has already created the one we care about -applicationDidFinishLaunching. This function invokes whene your app will finish to launch and if you want to do at that time then write in this function.
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Override point for customization after application launch
[window makeKeyAndVisible];
}
// Override point for customization after application launch
[window makeKeyAndVisible];
}
Now lets start some design on interface builder. For that open your xcode project and in classes, expand it and you will see two design files for your classes. There is HelloWorldViewController.xib file which is mapped to your controller class “HelloWorldViewController.h. For now I just want to change in HelloWorldViewController.xib file. Double click on that file to open it inside interface builder.
Here is the interface builder
Drag & drop the label object from library to view controller
Click on Tools and select Libaray (cmd + shift + L) and drag the label object library to view controller. As label is already selected, click on Tools>Inspector (cmd + 1) and in Text field type “Your Name”.
Now drag the TextField from Library to your view (cmd+shift+L) and also drag another. Make sure label is selected, Click on tools and select “Size Inspector” (cmd + 3) and change the width of this text field to 250. Also go to tools and select Inspector, change the layout to center.
Same like adding label and textfield add the button in view controller
Now open Xcode project and select HelloWorldViewController.h file and type the following code inside interface:
IBOutlet UITextField *txtUserName;
IBOutlet UILabel *lblUserTypedName;
also write IBAction
- (IBAction) submitYourName;
So your HelloWorldViewController.h file will look like this:
#import <UIKit/UIKit.h>
@interface HelloWorldViewController : UIViewController {
IBOutlet UITextField *txtUserName;
IBOutlet UILabel *lblUserTypedName;
}- (IBAction) submitYourName;
@end
Now open HelloWorldViewController.m file and type this method before @end
-(IBAction) submitYourName
{
lblUserTypedName.text = txtUserName.text;
}
Now map the controller class variable function and methods with interface builder. Select File’s Owner in Interface builder and select connection inspector from Tools cmd + 2.
Now you can see that two new variables are added in connection inspector txtUserName and lblUserTypedName. Click on txtUserName radio button and drag it to text field in view (as you can see in the image).
Do the same with lblUserTypedName, select its radio and drag it to below label.
Now the last step is, click on submitYourName radio and drag it to the button and select touch down from the list.
map your button with interface builder :
Now close the interface and open xcode. Either press cmd + r or cmd + enter or simply press of “build and go” button to run this hello world application. It will open the simulator in iPhone.
Final output.
You can grab example code from here.
Thanks for:
The Reddest
Adeem Basraa
Hello dear this is my first post. I will try to post one by every tool from my self or collecting from different uploaders so you can get related stuff in one place and learn easily step by step
ReplyDelete