Check Box Application In iPhone

In this application we will see how to CheckBox implement in iPhone. So let see how it will worked.

Step 1: Open the Xcode, Create a new project using View Base application. Give the application “CheckBox”.

Step 2: Xcode automatically creates the directory structure and adds essential frameworks to it. You can explore the directory structure to check out the content of the directory.

Step 3: Expand classes and notice Interface Builder created the ViewController class for you. Expand Resources and notice the template generated a separate nib, CheckBoxViewController.xib for the CheckBox application.

Step 4: Open the CheckBoxViewController.h file and make the following changes:

 

#import <uikit/UIKit.h>
@interface CheckboxViewController : UIViewController {
BOOL boxSelected;
IBOutlet UIButton *checkbox;
}
- (IBAction)SelectButton:(id)sender;
@end

 

 

Step 6: Double click the CheckBoxViewController.xib file and open it to the interface Builder. Drag the round rect button from the library and place it to the View window. Now select the button and bring up Attribute inspector and select the image “checkbox.png” and bring up Connection Inspector and connect Touch Up Inside to the File’s Owner icon and select SelectButton: method. Now Save the .xib file, close it and go back to the Xcode.

Step 7: Open the CheckBoxViewController.m file and make the following changes:

 

#import "CheckboxViewController.h"
@implementation CheckboxViewController
- (IBAction)SelectButton:(id)sender{
if (boxSelected == 0){
[checkbox setSelected:YES];
boxSelected = 1;
} else {
[checkbox setSelected:NO];
boxSelected = 0;
}
}
- (void)viewDidLoad {
boxSelected == 0;
[super viewDidLoad];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
// Release anything that's not essential, such as cached data
}
- (void)dealloc {
[super dealloc];
}
@end

 

 

Step 8: Now Compile and run the application on the Simulator.