How to Change background color after pressing Button in iPhone

In this application we will see how to change background color using button pressed. So let see how it will worked.  My previous post you can find out from here  ButtonPressed

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

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: Open the BackgroungColorViewController.h file and make the following changes in the file

#import <UIKit/UIKit.h>

@interface BackgroungColorViewController : UIViewController {

IBOutlet UIButton*firstButton;
IBOutlet UIButton*secondButton;
IBOutlet UIButton*thirdButton;
}

(IBAction)FirstButtonPressed:(id)sender;
(IBAction)SecondButtonPressed:(id)sender;
(IBAction)ThirdButtonPressed:(id)sender;

@end

Step 4: Double click the BackgroungColorViewController.xib file and open it to the Interface Builder. First drag the three Round Rect Button and place it to the view window. Select the first button and bring up Connection Inspector and connect Touch Up Inside to the Files Owner icon and select FirstButtonPressed: method. Do the same thing for other two buttons and select SecondButtonPressed: and ThirdButtonPressed: method. Now save the .xib file, close it and go back to the Xcode.

Step 5: In the BackgroungColorViewController.m file make the following changes:

#import "BackgroungColorViewController.h"
@implementation BackgroungColorViewController

(IBAction)FirstButtonPressed:(id)sender
{
self.view.backgroundColor = [UIColor greenColor];
}

(IBAction)SecondButtonPressed:(id)sender
{
self.view.backgroundColor = [UIColor yellowColor];
}

(IBAction)ThirdButtonPressed:(id)sender
{
self.view.backgroundColor = [UIColor redColor];
}

(void)dealloc
{
[super dealloc];
}

(void)didReceiveMemoryWarning
{
// Releases the view if it doesn’t have a superview.
[super didReceiveMemoryWarning];

// Release any cached data, images, etc that aren’t in use.
}

#pragma mark – View lifecycle

/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
– (void)viewDidLoad
{
[super viewDidLoad];
}
*/

(void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}

(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end

Step 6: Now compile and run the application on the simulator.

You can Download SourceCode from here BackgroungColor

How to Change background color after pressing Button in iPhone

In this application we will see how to change background color using button pressed. So let see how it will worked.  My previous post you can find out from here  ButtonPressed

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

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: Open the BackgroungColorViewController.h file and make the following changes in the file

#import <UIKit/UIKit.h>

@interface BackgroungColorViewController : UIViewController {

IBOutlet UIButton*firstButton;
IBOutlet UIButton*secondButton;
IBOutlet UIButton*thirdButton;
}

(IBAction)FirstButtonPressed:(id)sender;
(IBAction)SecondButtonPressed:(id)sender;
(IBAction)ThirdButtonPressed:(id)sender;

@end

Step 4: Double click the BackgroungColorViewController.xib file and open it to the Interface Builder. First drag the three Round Rect Button and place it to the view window. Select the first button and bring up Connection Inspector and connect Touch Up Inside to the Files Owner icon and select FirstButtonPressed: method. Do the same thing for other two buttons and select SecondButtonPressed: and ThirdButtonPressed: method. Now save the .xib file, close it and go back to the Xcode.

Step 5: In the BackgroungColorViewController.m file make the following changes:

#import "BackgroungColorViewController.h"
@implementation BackgroungColorViewController

(IBAction)FirstButtonPressed:(id)sender
{
self.view.backgroundColor = [UIColor greenColor];
}

(IBAction)SecondButtonPressed:(id)sender
{
self.view.backgroundColor = [UIColor yellowColor];
}

(IBAction)ThirdButtonPressed:(id)sender
{
self.view.backgroundColor = [UIColor redColor];
}

(void)dealloc
{
[super dealloc];
}

(void)didReceiveMemoryWarning
{
// Releases the view if it doesn’t have a superview.
[super didReceiveMemoryWarning];

// Release any cached data, images, etc that aren’t in use.
}

#pragma mark – View lifecycle

/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
– (void)viewDidLoad
{
[super viewDidLoad];
}
*/

(void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}

(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end

Step 6: Now compile and run the application on the simulator.

You can Download SourceCode from here BackgroungColor

How to Change background color after pressing Button in iPhone

In this application we will see how to change background color using button pressed. So let see how it will worked.  My previous post you can find out from here  ButtonPressed

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

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: Open the BackgroungColorViewController.h file and make the following changes in the file

#import <UIKit/UIKit.h>

@interface BackgroungColorViewController : UIViewController {

IBOutlet UIButton*firstButton;
IBOutlet UIButton*secondButton;
IBOutlet UIButton*thirdButton;
}

(IBAction)FirstButtonPressed:(id)sender;
(IBAction)SecondButtonPressed:(id)sender;
(IBAction)ThirdButtonPressed:(id)sender;

@end

Step 4: Double click the BackgroungColorViewController.xib file and open it to the Interface Builder. First drag the three Round Rect Button and place it to the view window. Select the first button and bring up Connection Inspector and connect Touch Up Inside to the Files Owner icon and select FirstButtonPressed: method. Do the same thing for other two buttons and select SecondButtonPressed: and ThirdButtonPressed: method. Now save the .xib file, close it and go back to the Xcode.

Step 5: In the BackgroungColorViewController.m file make the following changes:

#import "BackgroungColorViewController.h"
@implementation BackgroungColorViewController

(IBAction)FirstButtonPressed:(id)sender
{
self.view.backgroundColor = [UIColor greenColor];
}

(IBAction)SecondButtonPressed:(id)sender
{
self.view.backgroundColor = [UIColor yellowColor];
}

(IBAction)ThirdButtonPressed:(id)sender
{
self.view.backgroundColor = [UIColor redColor];
}

(void)dealloc
{
[super dealloc];
}

(void)didReceiveMemoryWarning
{
// Releases the view if it doesn’t have a superview.
[super didReceiveMemoryWarning];

// Release any cached data, images, etc that aren’t in use.
}

#pragma mark – View lifecycle

/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
– (void)viewDidLoad
{
[super viewDidLoad];
}
*/

(void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}

(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end

Step 6: Now compile and run the application on the simulator.

You can Download SourceCode from here BackgroungColor

How to Change background color after pressing Button in iPhone

In this application we will see how to change background color using button pressed. So let see how it will worked.  My previous post you can find out from here  ButtonPressed

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

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: Open the BackgroungColorViewController.h file and make the following changes in the file

#import <UIKit/UIKit.h>

@interface BackgroungColorViewController : UIViewController {

IBOutlet UIButton*firstButton;
IBOutlet UIButton*secondButton;
IBOutlet UIButton*thirdButton;
}

(IBAction)FirstButtonPressed:(id)sender;
(IBAction)SecondButtonPressed:(id)sender;
(IBAction)ThirdButtonPressed:(id)sender;

@end

Step 4: Double click the BackgroungColorViewController.xib file and open it to the Interface Builder. First drag the three Round Rect Button and place it to the view window. Select the first button and bring up Connection Inspector and connect Touch Up Inside to the Files Owner icon and select FirstButtonPressed: method. Do the same thing for other two buttons and select SecondButtonPressed: and ThirdButtonPressed: method. Now save the .xib file, close it and go back to the Xcode.

Step 5: In the BackgroungColorViewController.m file make the following changes:

#import "BackgroungColorViewController.h"
@implementation BackgroungColorViewController

(IBAction)FirstButtonPressed:(id)sender
{
self.view.backgroundColor = [UIColor greenColor];
}

(IBAction)SecondButtonPressed:(id)sender
{
self.view.backgroundColor = [UIColor yellowColor];
}

(IBAction)ThirdButtonPressed:(id)sender
{
self.view.backgroundColor = [UIColor redColor];
}

(void)dealloc
{
[super dealloc];
}

(void)didReceiveMemoryWarning
{
// Releases the view if it doesn’t have a superview.
[super didReceiveMemoryWarning];

// Release any cached data, images, etc that aren’t in use.
}

#pragma mark – View lifecycle

/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
– (void)viewDidLoad
{
[super viewDidLoad];
}
*/

(void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}

(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end

Step 6: Now compile and run the application on the simulator.

You can Download SourceCode from here BackgroungColor

ButtonPressed example in iPhone.

This is the ButtonPressed example. This is the very simple example. In this example we will see after pressing button message will display and dragging in the screen message will hide. So let see how it will worked. Another ButtonPress example you can find out from here ButtonPressed

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

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: Xpand classes and notice Interface Builder created the ButtonPressViewController class for you and generated a separate nib, ButtonFun_ViewViewController.xib for the “ButtonFun_View”.

Step 4: Open the ButtonFun_ViewViewController.h file and make the following chanages:

#import <UIKit/UIKit.h>

@interface ButtonFun_ViewViewController : UIViewController {

IBOutlet UIButton *button;
IBOutlet UILabel *label;
}

@property (nonatomic, retain) UIButton *button;
@property (nonatomic, retain) UILabel *label;
(IBAction) buttonPressed;

@end

Step 5: Double click the ButtonFun_ViewViewController.xib file and open it to the Interface Builder. First drag the Round Rect button from the library and place it to the view window, next drag the label from the library and place it to the view window. Select the Round Rect button and bring up Connection Inspector and connect Touch up Inside to the Files Owner icon and select buttonPressed: method. and connect Files Owner icon to the label and select label. Now save the .xib file, save it and go back to the Xcode.

Step 6: In the ButtonFun_ViewViewController.m file make the following changes:

#import "ButtonFun_ViewViewController.h"

@implementation ButtonFun_ViewViewController

@synthesize button;
@synthesize label;

(IBAction) buttonPressed {
label.text = @"Drag to hide label.";
}

(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{

button.hidden = YES;
label.hidden = YES;
}

(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
button.hidden = NO;
label.hidden = NO;
label.text = @"";
}

(void)dealloc
{
[super dealloc];
}

(void)didReceiveMemoryWarning
{
// Releases the view if it doesn’t have a superview.
[super didReceiveMemoryWarning];

// Release any cached data, images, etc that aren’t in use.
}

#pragma mark – View lifecycle

/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
– (void)viewDidLoad
{
[super viewDidLoad];
}
*/

(void)viewDidUnload
{
[super viewDidUnload];

}

(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end

Step 7: Now compile and run the application on the Simulator.

You can Download SourceCode from here ButtonFun_View

ButtonPressed example in iPhone.

This is the ButtonPressed example. This is the very simple example. In this example we will see after pressing button message will display and dragging in the screen message will hide. So let see how it will worked. Another ButtonPress example you can find out from here ButtonPressed

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

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: Xpand classes and notice Interface Builder created the ButtonPressViewController class for you and generated a separate nib, ButtonFun_ViewViewController.xib for the “ButtonFun_View”.

Step 4: Open the ButtonFun_ViewViewController.h file and make the following chanages:

#import <UIKit/UIKit.h>

@interface ButtonFun_ViewViewController : UIViewController {

IBOutlet UIButton *button;
IBOutlet UILabel *label;
}

@property (nonatomic, retain) UIButton *button;
@property (nonatomic, retain) UILabel *label;
(IBAction) buttonPressed;

@end

Step 5: Double click the ButtonFun_ViewViewController.xib file and open it to the Interface Builder. First drag the Round Rect button from the library and place it to the view window, next drag the label from the library and place it to the view window. Select the Round Rect button and bring up Connection Inspector and connect Touch up Inside to the Files Owner icon and select buttonPressed: method. and connect Files Owner icon to the label and select label. Now save the .xib file, save it and go back to the Xcode.

Step 6: In the ButtonFun_ViewViewController.m file make the following changes:

#import "ButtonFun_ViewViewController.h"

@implementation ButtonFun_ViewViewController

@synthesize button;
@synthesize label;

(IBAction) buttonPressed {
label.text = @"Drag to hide label.";
}

(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{

button.hidden = YES;
label.hidden = YES;
}

(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
button.hidden = NO;
label.hidden = NO;
label.text = @"";
}

(void)dealloc
{
[super dealloc];
}

(void)didReceiveMemoryWarning
{
// Releases the view if it doesn’t have a superview.
[super didReceiveMemoryWarning];

// Release any cached data, images, etc that aren’t in use.
}

#pragma mark – View lifecycle

/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
– (void)viewDidLoad
{
[super viewDidLoad];
}
*/

(void)viewDidUnload
{
[super viewDidUnload];

}

(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end

Step 7: Now compile and run the application on the Simulator.

You can Download SourceCode from here ButtonFun_View

ButtonPressed example in iPhone.

This is the ButtonPressed example. This is the very simple example. In this example we will see after pressing button message will display and dragging in the screen message will hide. So let see how it will worked. Another ButtonPress example you can find out from here ButtonPressed

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

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: Xpand classes and notice Interface Builder created the ButtonPressViewController class for you and generated a separate nib, ButtonFun_ViewViewController.xib for the “ButtonFun_View”.

Step 4: Open the ButtonFun_ViewViewController.h file and make the following chanages:

#import <UIKit/UIKit.h>

@interface ButtonFun_ViewViewController : UIViewController {

IBOutlet UIButton *button;
IBOutlet UILabel *label;
}

@property (nonatomic, retain) UIButton *button;
@property (nonatomic, retain) UILabel *label;
(IBAction) buttonPressed;

@end

Step 5: Double click the ButtonFun_ViewViewController.xib file and open it to the Interface Builder. First drag the Round Rect button from the library and place it to the view window, next drag the label from the library and place it to the view window. Select the Round Rect button and bring up Connection Inspector and connect Touch up Inside to the Files Owner icon and select buttonPressed: method. and connect Files Owner icon to the label and select label. Now save the .xib file, save it and go back to the Xcode.

Step 6: In the ButtonFun_ViewViewController.m file make the following changes:

#import "ButtonFun_ViewViewController.h"

@implementation ButtonFun_ViewViewController

@synthesize button;
@synthesize label;

(IBAction) buttonPressed {
label.text = @"Drag to hide label.";
}

(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{

button.hidden = YES;
label.hidden = YES;
}

(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
button.hidden = NO;
label.hidden = NO;
label.text = @"";
}

(void)dealloc
{
[super dealloc];
}

(void)didReceiveMemoryWarning
{
// Releases the view if it doesn’t have a superview.
[super didReceiveMemoryWarning];

// Release any cached data, images, etc that aren’t in use.
}

#pragma mark – View lifecycle

/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
– (void)viewDidLoad
{
[super viewDidLoad];
}
*/

(void)viewDidUnload
{
[super viewDidUnload];

}

(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end

Step 7: Now compile and run the application on the Simulator.

You can Download SourceCode from here ButtonFun_View

ButtonPressed example in iPhone.

This is the ButtonPressed example. This is the very simple example. In this example we will see after pressing button message will display and dragging in the screen message will hide. So let see how it will worked. Another ButtonPress example you can find out from here ButtonPressed

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

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: Xpand classes and notice Interface Builder created the ButtonPressViewController class for you and generated a separate nib, ButtonFun_ViewViewController.xib for the “ButtonFun_View”.

Step 4: Open the ButtonFun_ViewViewController.h file and make the following chanages:

#import <UIKit/UIKit.h>

@interface ButtonFun_ViewViewController : UIViewController {

IBOutlet UIButton *button;
IBOutlet UILabel *label;
}

@property (nonatomic, retain) UIButton *button;
@property (nonatomic, retain) UILabel *label;
(IBAction) buttonPressed;

@end

Step 5: Double click the ButtonFun_ViewViewController.xib file and open it to the Interface Builder. First drag the Round Rect button from the library and place it to the view window, next drag the label from the library and place it to the view window. Select the Round Rect button and bring up Connection Inspector and connect Touch up Inside to the Files Owner icon and select buttonPressed: method. and connect Files Owner icon to the label and select label. Now save the .xib file, save it and go back to the Xcode.

Step 6: In the ButtonFun_ViewViewController.m file make the following changes:

#import "ButtonFun_ViewViewController.h"

@implementation ButtonFun_ViewViewController

@synthesize button;
@synthesize label;

(IBAction) buttonPressed {
label.text = @"Drag to hide label.";
}

(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{

button.hidden = YES;
label.hidden = YES;
}

(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
button.hidden = NO;
label.hidden = NO;
label.text = @"";
}

(void)dealloc
{
[super dealloc];
}

(void)didReceiveMemoryWarning
{
// Releases the view if it doesn’t have a superview.
[super didReceiveMemoryWarning];

// Release any cached data, images, etc that aren’t in use.
}

#pragma mark – View lifecycle

/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
– (void)viewDidLoad
{
[super viewDidLoad];
}
*/

(void)viewDidUnload
{
[super viewDidUnload];

}

(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end

Step 7: Now compile and run the application on the Simulator.

You can Download SourceCode from here ButtonFun_View

Time Converter Application in iPhone

This is the Time Converter application. Using this application we can can convert time like, Hour to Minute, Hour to Second. So let see how it will worked. My previous topic reference you can find out from here PickerView Programmatically

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

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: We need to add images in the resource folder.

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

#import <UIKit/UIKit.h>

@interface PickerView_UsingButtonPressViewController : UIViewController {

NSMutableArray *array_from;
NSMutableArray *array_to;
UIPickerView *fromPickerView;
UIPickerView *toPickerView;
UIButton *doneButton ;
UITextField *fromButton;
UIButton *button1;

UIImageView *m_objBackgroundView;

UITextField *toTextButton;
UIButton *toButton;

IBOutlet UILabel*resultLabel;
IBOutlet UITextField *valueData;
IBOutlet UILabel*UnitLabel;

}
@property(nonatomic,retain) IBOutlet UITextField *fromButton;
@property(nonatomic,retain) IBOutlet   UIButton *button1;
@property(nonatomic,retain) IBOutlet UITextField *toTextButton;
@property(nonatomic,retain) IBOutlet   UIButton *toButton;

(IBAction)FromButton:(id)sender;
(IBAction)ToButton:(id)sender;
(IBAction)Calculation:(id)sender;

@end

Step 5: Double click the PickerView_usingButtonPress.xib file and open it to the Interface Builder. First drag the three label from the library and place it to the view window. Give the label name Value:, From: and To: . And drag the three  TextField from the library and place it to the view window. Connect Files Owner icon to the textfield and select valueData, fromButton and toTextButton. Now drag the Round Rect Button from the library and place it to the view window. Select the Round Rect Button and bring up Connection Inspector and connect Touch Up inside to the File’s Owner icon and select Calculation: method. Now save the .xib file, close it and go back to the Xcode.

Step 6: In the PickerView_usingButtonPress.m file and make the following changes:

#import "PickerView_UsingButtonPressViewController.h"

#define kPICKERCOLUMN 1
#define kFROMPICKERTAG 20
#define kTOPICKERTAG 21

@implementation PickerView_UsingButtonPressViewController

@synthesize fromButton,button1,toTextButton,toButton;

(IBAction)ToButton:(id)sender
{
 
    toPickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 200, 320, 200)];
    toPickerView.tag = kTOPICKERTAG;
   
    [self.view addSubview:toPickerView];
    toPickerView.delegate = self;
    toPickerView.showsSelectionIndicator = YES;
   
    doneButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [doneButton addTarget:self
                   action:@selector(ToPickerViewRemove:)
         forControlEvents:UIControlEventTouchDown];
    doneButton.frame = CGRectMake(265.0,202.0,  52.0, 30.0);
    UIImage *img = [UIImage imageNamed:@"done.png"];
    [doneButton setImage:img forState:UIControlStateNormal];
   
    [img release];
   
    [self.view addSubview:doneButton];
   
     
}

(IBAction)FromButton:(id)sender
{
    fromPickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 200, 320, 200)];
    fromPickerView.tag = kFROMPICKERTAG;
    [self.view addSubview:fromPickerView];
    fromPickerView.delegate = self;
    fromPickerView.showsSelectionIndicator = YES;
   
    doneButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [doneButton addTarget:self
                   action:@selector(FromPickerViewRemove:)
         forControlEvents:UIControlEventTouchDown];
    doneButton.frame = CGRectMake(265.0,202.0,  52.0, 30.0);
    UIImage *img = [UIImage imageNamed:@"done.png"];
    [doneButton setImage:img forState:UIControlStateNormal];
   
    [img release];
   
    [self.view addSubview:doneButton];
 
}

(IBAction)ToPickerViewRemove:(id)sender
{
    [toPickerView removeFromSuperview];
    [doneButton removeFromSuperview];
    [m_objBackgroundView removeFromSuperview];
}

(IBAction)FromPickerViewRemove:(id)sender
{
    [fromPickerView removeFromSuperview];
    [doneButton removeFromSuperview];
    [m_objBackgroundView removeFromSuperview];
}

(id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

(void)dealloc
{
    [super dealloc];
}

(void)didReceiveMemoryWarning
{
    // Releases the view if it doesn’t have a superview.
    [super didReceiveMemoryWarning];
   
    // Release any cached data, images, etc that aren’t in use.
}

#pragma mark – View lifecycle

(void)viewDidLoad
{
    [super viewDidLoad];
   
    array_from=[[NSMutableArray alloc]initWithObjects:@"Hour",nil];
   array_to=[[NSMutableArray alloc]initWithObjects:@"Hour",@"Minute",@"Second",nil];

    [super viewDidLoad];
   
 
}

(BOOL)textFieldShouldReturn:(UITextField *)textField{
        [textField resignFirstResponder];
        return YES;
}

(void)viewDidUnload
{
    [super viewDidUnload];
   
}

(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
   
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
   
    if (pickerView.tag == kFROMPICKERTAG)
        return [array_from count];
    else
        return [array_to count];
}

(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
    return kPICKERCOLUMN;
}

(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
   
   
    if (pickerView.tag == kFROMPICKERTAG){
             
        [fromButton setText:[NSString stringWithFormat:@"%@",[array_from objectAtIndex:[pickerView selectedRowInComponent:0]]]];
       
       
    }
    else{
       
         [toTextButton setText:[NSString stringWithFormat:@"%@",[array_to objectAtIndex:[pickerView selectedRowInComponent:0]]]];
    }
   
}

(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
    if (pickerView.tag == kFROMPICKERTAG){    
               
        return [array_from objectAtIndex:row];
      }
       
    else{
               
        return [array_to objectAtIndex:row];
    }
     
}

(IBAction)Calculation:(id)sender{
   
    NSString *tempString=fromButton.text;
    NSString *tempString1=toTextButton.text;
   
    NSString *string=@"Hour";
    NSString *string1=@"Minute";
    NSString *string2=@"Second";
   
   
    // From Hour To Hour
   
    if([tempString isEqualToString:string] && [tempString1 isEqualToString:string]){
       
        resultLabel = [[UILabel alloc]initWithFrame:CGRectMake(104, 300, 187, 20)];
        resultLabel.text =  valueData.text;
        [self.view addSubview:resultLabel];
        UnitLabel = [[UILabel alloc]initWithFrame:CGRectMake(104, 321, 187, 20)];
        UnitLabel.text = @"hour";
        [self.view addSubview:UnitLabel];
    }
   
    // From Hour To Minute
   
    if([tempString isEqualToString:string] && [tempString1 isEqualToString:string1]){
        int Result;
        NSString *str;
        int x = [valueData.text intValue];
        Result = (60*x);
        str = [NSString stringWithFormat:@"%d", Result];
        resultLabel = [[UILabel alloc]initWithFrame:CGRectMake(104, 300, 187, 20)];
        resultLabel.text =  str;
        [self.view addSubview:resultLabel];
       
        UnitLabel = [[UILabel alloc]initWithFrame:CGRectMake(104, 321, 187, 20)];
        UnitLabel.text = @"minute";
        [self.view addSubview:UnitLabel];
       
    }
   
    //  From Hour To Second
   
    if([tempString isEqualToString:string] && [tempString1 isEqualToString:string2]){
        int Result;
        int x = [valueData.text intValue];
        Result = (60*60*x);
        NSString *str;
        str = [NSString stringWithFormat:@"%d", Result];
        resultLabel = [[UILabel alloc]initWithFrame:CGRectMake(104, 300, 187, 20)];
        resultLabel.text =  str ;
        [self.view addSubview:resultLabel];
       
        UnitLabel = [[UILabel alloc]initWithFrame:CGRectMake(104, 321, 187, 20)];
        UnitLabel.text = @"second";
        [self.view addSubview:UnitLabel];
     
    }
   
}

// tell the picker the width of each row for a given component
(CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component {
    CGFloat componentWidth = 0.0;
        componentWidth = 135.0; // second column is narrower to show numbers
       
        return componentWidth;
}

@end

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

You can Download SourceCode from here PickerView_UsingButtonPress

Time Converter Application in iPhone

This is the Time Converter application. Using this application we can can convert time like, Hour to Minute, Hour to Second. So let see how it will worked. My previous topic reference you can find out from here PickerView Programmatically

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

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: We need to add images in the resource folder.

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

#import <UIKit/UIKit.h>

@interface PickerView_UsingButtonPressViewController : UIViewController {

NSMutableArray *array_from;
NSMutableArray *array_to;
UIPickerView *fromPickerView;
UIPickerView *toPickerView;
UIButton *doneButton ;
UITextField *fromButton;
UIButton *button1;

UIImageView *m_objBackgroundView;

UITextField *toTextButton;
UIButton *toButton;

IBOutlet UILabel*resultLabel;
IBOutlet UITextField *valueData;
IBOutlet UILabel*UnitLabel;

}
@property(nonatomic,retain) IBOutlet UITextField *fromButton;
@property(nonatomic,retain) IBOutlet   UIButton *button1;
@property(nonatomic,retain) IBOutlet UITextField *toTextButton;
@property(nonatomic,retain) IBOutlet   UIButton *toButton;

(IBAction)FromButton:(id)sender;
(IBAction)ToButton:(id)sender;
(IBAction)Calculation:(id)sender;

@end

Step 5: Double click the PickerView_usingButtonPress.xib file and open it to the Interface Builder. First drag the three label from the library and place it to the view window. Give the label name Value:, From: and To: . And drag the three  TextField from the library and place it to the view window. Connect Files Owner icon to the textfield and select valueData, fromButton and toTextButton. Now drag the Round Rect Button from the library and place it to the view window. Select the Round Rect Button and bring up Connection Inspector and connect Touch Up inside to the File’s Owner icon and select Calculation: method. Now save the .xib file, close it and go back to the Xcode.

Step 6: In the PickerView_usingButtonPress.m file and make the following changes:

#import "PickerView_UsingButtonPressViewController.h"

#define kPICKERCOLUMN 1
#define kFROMPICKERTAG 20
#define kTOPICKERTAG 21

@implementation PickerView_UsingButtonPressViewController

@synthesize fromButton,button1,toTextButton,toButton;

(IBAction)ToButton:(id)sender
{
 
    toPickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 200, 320, 200)];
    toPickerView.tag = kTOPICKERTAG;
   
    [self.view addSubview:toPickerView];
    toPickerView.delegate = self;
    toPickerView.showsSelectionIndicator = YES;
   
    doneButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [doneButton addTarget:self
                   action:@selector(ToPickerViewRemove:)
         forControlEvents:UIControlEventTouchDown];
    doneButton.frame = CGRectMake(265.0,202.0,  52.0, 30.0);
    UIImage *img = [UIImage imageNamed:@"done.png"];
    [doneButton setImage:img forState:UIControlStateNormal];
   
    [img release];
   
    [self.view addSubview:doneButton];
   
     
}

(IBAction)FromButton:(id)sender
{
    fromPickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 200, 320, 200)];
    fromPickerView.tag = kFROMPICKERTAG;
    [self.view addSubview:fromPickerView];
    fromPickerView.delegate = self;
    fromPickerView.showsSelectionIndicator = YES;
   
    doneButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [doneButton addTarget:self
                   action:@selector(FromPickerViewRemove:)
         forControlEvents:UIControlEventTouchDown];
    doneButton.frame = CGRectMake(265.0,202.0,  52.0, 30.0);
    UIImage *img = [UIImage imageNamed:@"done.png"];
    [doneButton setImage:img forState:UIControlStateNormal];
   
    [img release];
   
    [self.view addSubview:doneButton];
 
}

(IBAction)ToPickerViewRemove:(id)sender
{
    [toPickerView removeFromSuperview];
    [doneButton removeFromSuperview];
    [m_objBackgroundView removeFromSuperview];
}

(IBAction)FromPickerViewRemove:(id)sender
{
    [fromPickerView removeFromSuperview];
    [doneButton removeFromSuperview];
    [m_objBackgroundView removeFromSuperview];
}

(id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

(void)dealloc
{
    [super dealloc];
}

(void)didReceiveMemoryWarning
{
    // Releases the view if it doesn’t have a superview.
    [super didReceiveMemoryWarning];
   
    // Release any cached data, images, etc that aren’t in use.
}

#pragma mark – View lifecycle

(void)viewDidLoad
{
    [super viewDidLoad];
   
    array_from=[[NSMutableArray alloc]initWithObjects:@"Hour",nil];
   array_to=[[NSMutableArray alloc]initWithObjects:@"Hour",@"Minute",@"Second",nil];

    [super viewDidLoad];
   
 
}

(BOOL)textFieldShouldReturn:(UITextField *)textField{
        [textField resignFirstResponder];
        return YES;
}

(void)viewDidUnload
{
    [super viewDidUnload];
   
}

(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
   
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
   
    if (pickerView.tag == kFROMPICKERTAG)
        return [array_from count];
    else
        return [array_to count];
}

(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
    return kPICKERCOLUMN;
}

(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
   
   
    if (pickerView.tag == kFROMPICKERTAG){
             
        [fromButton setText:[NSString stringWithFormat:@"%@",[array_from objectAtIndex:[pickerView selectedRowInComponent:0]]]];
       
       
    }
    else{
       
         [toTextButton setText:[NSString stringWithFormat:@"%@",[array_to objectAtIndex:[pickerView selectedRowInComponent:0]]]];
    }
   
}

(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
    if (pickerView.tag == kFROMPICKERTAG){    
               
        return [array_from objectAtIndex:row];
      }
       
    else{
               
        return [array_to objectAtIndex:row];
    }
     
}

(IBAction)Calculation:(id)sender{
   
    NSString *tempString=fromButton.text;
    NSString *tempString1=toTextButton.text;
   
    NSString *string=@"Hour";
    NSString *string1=@"Minute";
    NSString *string2=@"Second";
   
   
    // From Hour To Hour
   
    if([tempString isEqualToString:string] && [tempString1 isEqualToString:string]){
       
        resultLabel = [[UILabel alloc]initWithFrame:CGRectMake(104, 300, 187, 20)];
        resultLabel.text =  valueData.text;
        [self.view addSubview:resultLabel];
        UnitLabel = [[UILabel alloc]initWithFrame:CGRectMake(104, 321, 187, 20)];
        UnitLabel.text = @"hour";
        [self.view addSubview:UnitLabel];
    }
   
    // From Hour To Minute
   
    if([tempString isEqualToString:string] && [tempString1 isEqualToString:string1]){
        int Result;
        NSString *str;
        int x = [valueData.text intValue];
        Result = (60*x);
        str = [NSString stringWithFormat:@"%d", Result];
        resultLabel = [[UILabel alloc]initWithFrame:CGRectMake(104, 300, 187, 20)];
        resultLabel.text =  str;
        [self.view addSubview:resultLabel];
       
        UnitLabel = [[UILabel alloc]initWithFrame:CGRectMake(104, 321, 187, 20)];
        UnitLabel.text = @"minute";
        [self.view addSubview:UnitLabel];
       
    }
   
    //  From Hour To Second
   
    if([tempString isEqualToString:string] && [tempString1 isEqualToString:string2]){
        int Result;
        int x = [valueData.text intValue];
        Result = (60*60*x);
        NSString *str;
        str = [NSString stringWithFormat:@"%d", Result];
        resultLabel = [[UILabel alloc]initWithFrame:CGRectMake(104, 300, 187, 20)];
        resultLabel.text =  str ;
        [self.view addSubview:resultLabel];
       
        UnitLabel = [[UILabel alloc]initWithFrame:CGRectMake(104, 321, 187, 20)];
        UnitLabel.text = @"second";
        [self.view addSubview:UnitLabel];
     
    }
   
}

// tell the picker the width of each row for a given component
(CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component {
    CGFloat componentWidth = 0.0;
        componentWidth = 135.0; // second column is narrower to show numbers
       
        return componentWidth;
}

@end

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

You can Download SourceCode from here PickerView_UsingButtonPress

Time Converter Application in iPhone

This is the Time Converter application. Using this application we can can convert time like, Hour to Minute, Hour to Second. So let see how it will worked. My previous topic reference you can find out from here PickerView Programmatically

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

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: We need to add images in the resource folder.

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

#import <UIKit/UIKit.h>

@interface PickerView_UsingButtonPressViewController : UIViewController {

NSMutableArray *array_from;
NSMutableArray *array_to;
UIPickerView *fromPickerView;
UIPickerView *toPickerView;
UIButton *doneButton ;
UITextField *fromButton;
UIButton *button1;

UIImageView *m_objBackgroundView;

UITextField *toTextButton;
UIButton *toButton;

IBOutlet UILabel*resultLabel;
IBOutlet UITextField *valueData;
IBOutlet UILabel*UnitLabel;

}
@property(nonatomic,retain) IBOutlet UITextField *fromButton;
@property(nonatomic,retain) IBOutlet   UIButton *button1;
@property(nonatomic,retain) IBOutlet UITextField *toTextButton;
@property(nonatomic,retain) IBOutlet   UIButton *toButton;

(IBAction)FromButton:(id)sender;
(IBAction)ToButton:(id)sender;
(IBAction)Calculation:(id)sender;

@end

Step 5: Double click the PickerView_usingButtonPress.xib file and open it to the Interface Builder. First drag the three label from the library and place it to the view window. Give the label name Value:, From: and To: . And drag the three  TextField from the library and place it to the view window. Connect Files Owner icon to the textfield and select valueData, fromButton and toTextButton. Now drag the Round Rect Button from the library and place it to the view window. Select the Round Rect Button and bring up Connection Inspector and connect Touch Up inside to the File’s Owner icon and select Calculation: method. Now save the .xib file, close it and go back to the Xcode.

Step 6: In the PickerView_usingButtonPress.m file and make the following changes:

#import "PickerView_UsingButtonPressViewController.h"

#define kPICKERCOLUMN 1
#define kFROMPICKERTAG 20
#define kTOPICKERTAG 21

@implementation PickerView_UsingButtonPressViewController

@synthesize fromButton,button1,toTextButton,toButton;

(IBAction)ToButton:(id)sender
{
 
    toPickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 200, 320, 200)];
    toPickerView.tag = kTOPICKERTAG;
   
    [self.view addSubview:toPickerView];
    toPickerView.delegate = self;
    toPickerView.showsSelectionIndicator = YES;
   
    doneButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [doneButton addTarget:self
                   action:@selector(ToPickerViewRemove:)
         forControlEvents:UIControlEventTouchDown];
    doneButton.frame = CGRectMake(265.0,202.0,  52.0, 30.0);
    UIImage *img = [UIImage imageNamed:@"done.png"];
    [doneButton setImage:img forState:UIControlStateNormal];
   
    [img release];
   
    [self.view addSubview:doneButton];
   
     
}

(IBAction)FromButton:(id)sender
{
    fromPickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 200, 320, 200)];
    fromPickerView.tag = kFROMPICKERTAG;
    [self.view addSubview:fromPickerView];
    fromPickerView.delegate = self;
    fromPickerView.showsSelectionIndicator = YES;
   
    doneButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [doneButton addTarget:self
                   action:@selector(FromPickerViewRemove:)
         forControlEvents:UIControlEventTouchDown];
    doneButton.frame = CGRectMake(265.0,202.0,  52.0, 30.0);
    UIImage *img = [UIImage imageNamed:@"done.png"];
    [doneButton setImage:img forState:UIControlStateNormal];
   
    [img release];
   
    [self.view addSubview:doneButton];
 
}

(IBAction)ToPickerViewRemove:(id)sender
{
    [toPickerView removeFromSuperview];
    [doneButton removeFromSuperview];
    [m_objBackgroundView removeFromSuperview];
}

(IBAction)FromPickerViewRemove:(id)sender
{
    [fromPickerView removeFromSuperview];
    [doneButton removeFromSuperview];
    [m_objBackgroundView removeFromSuperview];
}

(id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

(void)dealloc
{
    [super dealloc];
}

(void)didReceiveMemoryWarning
{
    // Releases the view if it doesn’t have a superview.
    [super didReceiveMemoryWarning];
   
    // Release any cached data, images, etc that aren’t in use.
}

#pragma mark – View lifecycle

(void)viewDidLoad
{
    [super viewDidLoad];
   
    array_from=[[NSMutableArray alloc]initWithObjects:@"Hour",nil];
   array_to=[[NSMutableArray alloc]initWithObjects:@"Hour",@"Minute",@"Second",nil];

    [super viewDidLoad];
   
 
}

(BOOL)textFieldShouldReturn:(UITextField *)textField{
        [textField resignFirstResponder];
        return YES;
}

(void)viewDidUnload
{
    [super viewDidUnload];
   
}

(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
   
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
   
    if (pickerView.tag == kFROMPICKERTAG)
        return [array_from count];
    else
        return [array_to count];
}

(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
    return kPICKERCOLUMN;
}

(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
   
   
    if (pickerView.tag == kFROMPICKERTAG){
             
        [fromButton setText:[NSString stringWithFormat:@"%@",[array_from objectAtIndex:[pickerView selectedRowInComponent:0]]]];
       
       
    }
    else{
       
         [toTextButton setText:[NSString stringWithFormat:@"%@",[array_to objectAtIndex:[pickerView selectedRowInComponent:0]]]];
    }
   
}

(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
    if (pickerView.tag == kFROMPICKERTAG){    
               
        return [array_from objectAtIndex:row];
      }
       
    else{
               
        return [array_to objectAtIndex:row];
    }
     
}

(IBAction)Calculation:(id)sender{
   
    NSString *tempString=fromButton.text;
    NSString *tempString1=toTextButton.text;
   
    NSString *string=@"Hour";
    NSString *string1=@"Minute";
    NSString *string2=@"Second";
   
   
    // From Hour To Hour
   
    if([tempString isEqualToString:string] && [tempString1 isEqualToString:string]){
       
        resultLabel = [[UILabel alloc]initWithFrame:CGRectMake(104, 300, 187, 20)];
        resultLabel.text =  valueData.text;
        [self.view addSubview:resultLabel];
        UnitLabel = [[UILabel alloc]initWithFrame:CGRectMake(104, 321, 187, 20)];
        UnitLabel.text = @"hour";
        [self.view addSubview:UnitLabel];
    }
   
    // From Hour To Minute
   
    if([tempString isEqualToString:string] && [tempString1 isEqualToString:string1]){
        int Result;
        NSString *str;
        int x = [valueData.text intValue];
        Result = (60*x);
        str = [NSString stringWithFormat:@"%d", Result];
        resultLabel = [[UILabel alloc]initWithFrame:CGRectMake(104, 300, 187, 20)];
        resultLabel.text =  str;
        [self.view addSubview:resultLabel];
       
        UnitLabel = [[UILabel alloc]initWithFrame:CGRectMake(104, 321, 187, 20)];
        UnitLabel.text = @"minute";
        [self.view addSubview:UnitLabel];
       
    }
   
    //  From Hour To Second
   
    if([tempString isEqualToString:string] && [tempString1 isEqualToString:string2]){
        int Result;
        int x = [valueData.text intValue];
        Result = (60*60*x);
        NSString *str;
        str = [NSString stringWithFormat:@"%d", Result];
        resultLabel = [[UILabel alloc]initWithFrame:CGRectMake(104, 300, 187, 20)];
        resultLabel.text =  str ;
        [self.view addSubview:resultLabel];
       
        UnitLabel = [[UILabel alloc]initWithFrame:CGRectMake(104, 321, 187, 20)];
        UnitLabel.text = @"second";
        [self.view addSubview:UnitLabel];
     
    }
   
}

// tell the picker the width of each row for a given component
(CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component {
    CGFloat componentWidth = 0.0;
        componentWidth = 135.0; // second column is narrower to show numbers
       
        return componentWidth;
}

@end

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

You can Download SourceCode from here PickerView_UsingButtonPress

Time Converter Application in iPhone

This is the Time Converter application. Using this application we can can convert time like, Hour to Minute, Hour to Second. So let see how it will worked. My previous topic reference you can find out from here PickerView Programmatically

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

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: We need to add images in the resource folder.

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

#import <UIKit/UIKit.h>

@interface PickerView_UsingButtonPressViewController : UIViewController {

NSMutableArray *array_from;
NSMutableArray *array_to;
UIPickerView *fromPickerView;
UIPickerView *toPickerView;
UIButton *doneButton ;
UITextField *fromButton;
UIButton *button1;

UIImageView *m_objBackgroundView;

UITextField *toTextButton;
UIButton *toButton;

IBOutlet UILabel*resultLabel;
IBOutlet UITextField *valueData;
IBOutlet UILabel*UnitLabel;

}
@property(nonatomic,retain) IBOutlet UITextField *fromButton;
@property(nonatomic,retain) IBOutlet   UIButton *button1;
@property(nonatomic,retain) IBOutlet UITextField *toTextButton;
@property(nonatomic,retain) IBOutlet   UIButton *toButton;

(IBAction)FromButton:(id)sender;
(IBAction)ToButton:(id)sender;
(IBAction)Calculation:(id)sender;

@end

Step 5: Double click the PickerView_usingButtonPress.xib file and open it to the Interface Builder. First drag the three label from the library and place it to the view window. Give the label name Value:, From: and To: . And drag the three  TextField from the library and place it to the view window. Connect Files Owner icon to the textfield and select valueData, fromButton and toTextButton. Now drag the Round Rect Button from the library and place it to the view window. Select the Round Rect Button and bring up Connection Inspector and connect Touch Up inside to the File’s Owner icon and select Calculation: method. Now save the .xib file, close it and go back to the Xcode.

Step 6: In the PickerView_usingButtonPress.m file and make the following changes:

#import "PickerView_UsingButtonPressViewController.h"

#define kPICKERCOLUMN 1
#define kFROMPICKERTAG 20
#define kTOPICKERTAG 21

@implementation PickerView_UsingButtonPressViewController

@synthesize fromButton,button1,toTextButton,toButton;

(IBAction)ToButton:(id)sender
{
 
    toPickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 200, 320, 200)];
    toPickerView.tag = kTOPICKERTAG;
   
    [self.view addSubview:toPickerView];
    toPickerView.delegate = self;
    toPickerView.showsSelectionIndicator = YES;
   
    doneButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [doneButton addTarget:self
                   action:@selector(ToPickerViewRemove:)
         forControlEvents:UIControlEventTouchDown];
    doneButton.frame = CGRectMake(265.0,202.0,  52.0, 30.0);
    UIImage *img = [UIImage imageNamed:@"done.png"];
    [doneButton setImage:img forState:UIControlStateNormal];
   
    [img release];
   
    [self.view addSubview:doneButton];
   
     
}

(IBAction)FromButton:(id)sender
{
    fromPickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 200, 320, 200)];
    fromPickerView.tag = kFROMPICKERTAG;
    [self.view addSubview:fromPickerView];
    fromPickerView.delegate = self;
    fromPickerView.showsSelectionIndicator = YES;
   
    doneButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [doneButton addTarget:self
                   action:@selector(FromPickerViewRemove:)
         forControlEvents:UIControlEventTouchDown];
    doneButton.frame = CGRectMake(265.0,202.0,  52.0, 30.0);
    UIImage *img = [UIImage imageNamed:@"done.png"];
    [doneButton setImage:img forState:UIControlStateNormal];
   
    [img release];
   
    [self.view addSubview:doneButton];
 
}

(IBAction)ToPickerViewRemove:(id)sender
{
    [toPickerView removeFromSuperview];
    [doneButton removeFromSuperview];
    [m_objBackgroundView removeFromSuperview];
}

(IBAction)FromPickerViewRemove:(id)sender
{
    [fromPickerView removeFromSuperview];
    [doneButton removeFromSuperview];
    [m_objBackgroundView removeFromSuperview];
}

(id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

(void)dealloc
{
    [super dealloc];
}

(void)didReceiveMemoryWarning
{
    // Releases the view if it doesn’t have a superview.
    [super didReceiveMemoryWarning];
   
    // Release any cached data, images, etc that aren’t in use.
}

#pragma mark – View lifecycle

(void)viewDidLoad
{
    [super viewDidLoad];
   
    array_from=[[NSMutableArray alloc]initWithObjects:@"Hour",nil];
   array_to=[[NSMutableArray alloc]initWithObjects:@"Hour",@"Minute",@"Second",nil];

    [super viewDidLoad];
   
 
}

(BOOL)textFieldShouldReturn:(UITextField *)textField{
        [textField resignFirstResponder];
        return YES;
}

(void)viewDidUnload
{
    [super viewDidUnload];
   
}

(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
   
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
   
    if (pickerView.tag == kFROMPICKERTAG)
        return [array_from count];
    else
        return [array_to count];
}

(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
    return kPICKERCOLUMN;
}

(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
   
   
    if (pickerView.tag == kFROMPICKERTAG){
             
        [fromButton setText:[NSString stringWithFormat:@"%@",[array_from objectAtIndex:[pickerView selectedRowInComponent:0]]]];
       
       
    }
    else{
       
         [toTextButton setText:[NSString stringWithFormat:@"%@",[array_to objectAtIndex:[pickerView selectedRowInComponent:0]]]];
    }
   
}

(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
    if (pickerView.tag == kFROMPICKERTAG){    
               
        return [array_from objectAtIndex:row];
      }
       
    else{
               
        return [array_to objectAtIndex:row];
    }
     
}

(IBAction)Calculation:(id)sender{
   
    NSString *tempString=fromButton.text;
    NSString *tempString1=toTextButton.text;
   
    NSString *string=@"Hour";
    NSString *string1=@"Minute";
    NSString *string2=@"Second";
   
   
    // From Hour To Hour
   
    if([tempString isEqualToString:string] && [tempString1 isEqualToString:string]){
       
        resultLabel = [[UILabel alloc]initWithFrame:CGRectMake(104, 300, 187, 20)];
        resultLabel.text =  valueData.text;
        [self.view addSubview:resultLabel];
        UnitLabel = [[UILabel alloc]initWithFrame:CGRectMake(104, 321, 187, 20)];
        UnitLabel.text = @"hour";
        [self.view addSubview:UnitLabel];
    }
   
    // From Hour To Minute
   
    if([tempString isEqualToString:string] && [tempString1 isEqualToString:string1]){
        int Result;
        NSString *str;
        int x = [valueData.text intValue];
        Result = (60*x);
        str = [NSString stringWithFormat:@"%d", Result];
        resultLabel = [[UILabel alloc]initWithFrame:CGRectMake(104, 300, 187, 20)];
        resultLabel.text =  str;
        [self.view addSubview:resultLabel];
       
        UnitLabel = [[UILabel alloc]initWithFrame:CGRectMake(104, 321, 187, 20)];
        UnitLabel.text = @"minute";
        [self.view addSubview:UnitLabel];
       
    }
   
    //  From Hour To Second
   
    if([tempString isEqualToString:string] && [tempString1 isEqualToString:string2]){
        int Result;
        int x = [valueData.text intValue];
        Result = (60*60*x);
        NSString *str;
        str = [NSString stringWithFormat:@"%d", Result];
        resultLabel = [[UILabel alloc]initWithFrame:CGRectMake(104, 300, 187, 20)];
        resultLabel.text =  str ;
        [self.view addSubview:resultLabel];
       
        UnitLabel = [[UILabel alloc]initWithFrame:CGRectMake(104, 321, 187, 20)];
        UnitLabel.text = @"second";
        [self.view addSubview:UnitLabel];
     
    }
   
}

// tell the picker the width of each row for a given component
(CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component {
    CGFloat componentWidth = 0.0;
        componentWidth = 135.0; // second column is narrower to show numbers
       
        return componentWidth;
}

@end

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

You can Download SourceCode from here PickerView_UsingButtonPress

Using OS X with an SSD plus HDD setup

Solid-state drives (SSDs) are becoming commonplace, and the first time you use one as a boot drive, you realise why – they’re faster than hard drives to a ridiculous degree. The downside is they’re currently still very expensive compared to hard drives, such that only smaller capacities are currently affordable. Macs are now being offered with what I call “mixed drive” configurations, including both a (small; often 256 GB) SSD and an HDD, and many people wonder how to make the most of this setup.

I have two SSD-equipped machines here, including a mixed-drive iMac, and have recently configured it in what I believe is a good compromise setup to take advantage of SSD speed without sacrificing the roomy storage of a hard drive (or causing excessive wear to the SSD). This is just one possible setup, but I hope it’s useful to you.

The basic approach here is to have the OS on the SSD (the default setup on mixed-drive Macs), and to move certain folders onto the hard drive, providing links to those folders in the places they used to be. Before beginning, let me try to pre-empt two possible comments:

“You can tell iTunes (etc) to keep its data elsewhere!”

Indeed you can (usually by holding the alt/option key whilst launching the app), but you’ll have to do it for each and every app that has such a capability – and some apps won’t let you. The method I’m about to describe, however, will just work, without changing any settings.

“You can put the home folder on the hard drive, and use the Accounts pane to point to it!”

That’s also true (unlock the Accounts pane, then right-click on your account in the list), but you’re losing the speed benefit of having certain parts of your home folder on the SSD (such as caches, preferences, your development projects and so forth).

It’s your choice if you want to use one of the above limited expedients, but I feel that you can find a better balance by doing just a little bit of extra work.

Copying and Linking folders on the HDD

With that all said, let’s offload some folders to the hard drive. It’s extremely easy to do, even though there’s a tiny, tiny bit of typing on the Terminal involved. If you’re scared of that, by all means run away now and get a friend to help. Also, make sure you have an up-to-date backup of your boot drive before beginning; that’s just common sense.

We’re really just going to be repeating the same process over and over, once for each folder that you want to live on the HDD instead of the SDD. The process is simply this:

  1. In the Finder, copy the folder from the SSD to the HDD. Check that it was copied successfully.
  2. In Terminal, cd to the location of the original folder (on the SSD), and delete it via sudo rm -rf foldername.
  3. In Terminal, still in the location of the original folder you just deleted, make a link to the copy of the folder on the HDD, via ln -s /Volumes/HDDname/path/to/foldername.

(In steps 2 and 3 above, you should of course substitute the actual names and paths of the relevant folders and volume instead of ‘foldername’, ‘HDDname’, and ‘path/to/foldername’. Hopefully that’s obvious. For the ln command, think of the syntax as being “put a link here, that points to there“.)

That’s it. You’ll probably want to put all these copied folders somewhere sensible on the HDD; I created a folder called “matt” at the root of the HDD, and copied my folders into there – you can see a picture of it below. I’ve heard that you should not create a “Users” folder at the root of a non-boot disk, however.

List of folders moved onto a hard drive, and linked from the solid state drive

You should also note that, if you’ve copied and linked one of the “special” folders in your home directory (such as Pictures), the new folder/link won’t have the special icon that the Finder usually provides. That’s normal, and completely harmless. You may also need to re-add the folder to the Finder’s sidebar.

There’s nothing else to it, except to decide which folders to actually offload.

Choosing which folders to put on the HDD

This is a personal decision, but generally you’ll want to offload folders that fit any of these criteria:

  1. Are very large. Your SSD is small, and it shouldn’t be bursting at the seams.
  2. Will change extremely often, particularly if they contain large files. SSDs are notably subject to wear, especially if they don’t support TRIM.
  3. Contain files which aren’t involved in performance-critical work.

Try to keep in mind that the HDD is perfectly good enough for almost everything, and that we’ve been using HDDs for years. It’s not the poor cousin, and it hasn’t suddenly acquired the performance characteristics of a floppy disk drive. This is just about balance, and sensible optimisations to help get the most from the new SSD.

In my own case, I offloaded several of the folders in my home directory onto the HDD, as shown in the screenshot below.

List of folders in home folder on solid state drive, showing the following ones as links to the hard drive: Backups, Downloads, Dropbox, Movies and Pictures.

Note that the Dropbox folder is created by the utility of the same name, and that the Backups folder is one I created for my own use.

In addition to those, as shown in the picture, I offloaded Downloads, Movies and Pictures. I don’t keep things permanently in my Downloads folder yet its contents change constantly, so it was an excellent candidate for offloading. I also don’t heavily use iPhoto or Aperture, and keep my graphic work files in my Documents folder, so I could offload Pictures. I don’t do any video editing, and have a large Movies folder, so I offloaded it too.

I did not offload the Music folder, but I did offload the actual media files (and mobile apps) that iTunes uses, as shown in the picture of my Music folder’s contents below.

Contents of the Music folder, showing that the 'iTunes Music' folder (sometimes also called 'iTunes Media') within the iTunes folder is a link to a folder on the hard drive

Note that on your Mac, the “iTunes Music” folder may instead be called “iTunes Media”. The reason I didn’t offload the entire Music folder was to keep my GarageBand files on the SSD for performance, and nor did I offload the entire parent iTunes folder so that I could keep iTunes’ library and metadata files on the SSD for the same reason.

You may find that you’ll want to keep some of those folders on the SSD, and equally you may find that you want to offload additional folders to the HDD. For example, I also put my Virtual Machines folder on the HDD, and you might also want to put your Steam games there (they live in ~/Library/Application Support/Steam).

Just follow the same process as above, and you should be fine. It takes only a few minutes, and it should ensure that you get the maximum benefit from the SSD without being unduly hindered by its comparatively small capacity.

If you enjoyed this article, you may want to follow me (@mattgemmell) on Twitter, where I always announce new articles and projects. You may also want to read my biography, or hire me for your iPad, iPhone or Mac OS X app projects.

Using OS X with an SSD plus HDD setup

Solid-state drives (SSDs) are becoming commonplace, and the first time you use one as a boot drive, you realise why – they’re faster than hard drives to a ridiculous degree. The downside is they’re currently still very expensive compared to hard drives, such that only smaller capacities are currently affordable. Macs are now being offered with what I call “mixed drive” configurations, including both a (small; often 256 GB) SSD and an HDD, and many people wonder how to make the most of this setup.

I have two SSD-equipped machines here, including a mixed-drive iMac, and have recently configured it in what I believe is a good compromise setup to take advantage of SSD speed without sacrificing the roomy storage of a hard drive (or causing excessive wear to the SSD). This is just one possible setup, but I hope it’s useful to you.

The basic approach here is to have the OS on the SSD (the default setup on mixed-drive Macs), and to move certain folders onto the hard drive, providing links to those folders in the places they used to be. Before beginning, let me try to pre-empt two possible comments:

“You can tell iTunes (etc) to keep its data elsewhere!”

Indeed you can (usually by holding the alt/option key whilst launching the app), but you’ll have to do it for each and every app that has such a capability – and some apps won’t let you. The method I’m about to describe, however, will just work, without changing any settings.

“You can put the home folder on the hard drive, and use the Accounts pane to point to it!”

That’s also true (unlock the Accounts pane, then right-click on your account in the list), but you’re losing the speed benefit of having certain parts of your home folder on the SSD (such as caches, preferences, your development projects and so forth).

It’s your choice if you want to use one of the above limited expedients, but I feel that you can find a better balance by doing just a little bit of extra work.

Copying and Linking folders on the HDD

With that all said, let’s offload some folders to the hard drive. It’s extremely easy to do, even though there’s a tiny, tiny bit of typing on the Terminal involved. If you’re scared of that, by all means run away now and get a friend to help. Also, make sure you have an up-to-date backup of your boot drive before beginning; that’s just common sense.

We’re really just going to be repeating the same process over and over, once for each folder that you want to live on the HDD instead of the SDD. The process is simply this:

  1. In the Finder, copy the folder from the SSD to the HDD. Check that it was copied successfully.
  2. In Terminal, cd to the location of the original folder (on the SSD), and delete it via sudo rm -rf foldername.
  3. In Terminal, still in the location of the original folder you just deleted, make a link to the copy of the folder on the HDD, via ln -s /Volumes/HDDname/path/to/foldername.

(In steps 2 and 3 above, you should of course substitute the actual names and paths of the relevant folders and volume instead of ‘foldername’, ‘HDDname’, and ‘path/to/foldername’. Hopefully that’s obvious. For the ln command, think of the syntax as being “put a link here, that points to there“.)

That’s it. You’ll probably want to put all these copied folders somewhere sensible on the HDD; I created a folder called “matt” at the root of the HDD, and copied my folders into there – you can see a picture of it below. I’ve heard that you should not create a “Users” folder at the root of a non-boot disk, however.

List of folders moved onto a hard drive, and linked from the solid state drive

You should also note that, if you’ve copied and linked one of the “special” folders in your home directory (such as Pictures), the new folder/link won’t have the special icon that the Finder usually provides. That’s normal, and completely harmless. You may also need to re-add the folder to the Finder’s sidebar.

There’s nothing else to it, except to decide which folders to actually offload.

Choosing which folders to put on the HDD

This is a personal decision, but generally you’ll want to offload folders that fit any of these criteria:

  1. Are very large. Your SSD is small, and it shouldn’t be bursting at the seams.
  2. Will change extremely often, particularly if they contain large files. SSDs are notably subject to wear, especially if they don’t support TRIM.
  3. Contain files which aren’t involved in performance-critical work.

Try to keep in mind that the HDD is perfectly good enough for almost everything, and that we’ve been using HDDs for years. It’s not the poor cousin, and it hasn’t suddenly acquired the performance characteristics of a floppy disk drive. This is just about balance, and sensible optimisations to help get the most from the new SSD.

In my own case, I offloaded several of the folders in my home directory onto the HDD, as shown in the screenshot below.

List of folders in home folder on solid state drive, showing the following ones as links to the hard drive: Backups, Downloads, Dropbox, Movies and Pictures.

Note that the Dropbox folder is created by the utility of the same name, and that the Backups folder is one I created for my own use.

In addition to those, as shown in the picture, I offloaded Downloads, Movies and Pictures. I don’t keep things permanently in my Downloads folder yet its contents change constantly, so it was an excellent candidate for offloading. I also don’t heavily use iPhoto or Aperture, and keep my graphic work files in my Documents folder, so I could offload Pictures. I don’t do any video editing, and have a large Movies folder, so I offloaded it too.

I did not offload the Music folder, but I did offload the actual media files (and mobile apps) that iTunes uses, as shown in the picture of my Music folder’s contents below.

Contents of the Music folder, showing that the 'iTunes Music' folder (sometimes also called 'iTunes Media') within the iTunes folder is a link to a folder on the hard drive

Note that on your Mac, the “iTunes Music” folder may instead be called “iTunes Media”. The reason I didn’t offload the entire Music folder was to keep my GarageBand files on the SSD for performance, and nor did I offload the entire parent iTunes folder so that I could keep iTunes’ library and metadata files on the SSD for the same reason.

You may find that you’ll want to keep some of those folders on the SSD, and equally you may find that you want to offload additional folders to the HDD. For example, I also put my Virtual Machines folder on the HDD, and you might also want to put your Steam games there (they live in ~/Library/Application Support/Steam).

Just follow the same process as above, and you should be fine. It takes only a few minutes, and it should ensure that you get the maximum benefit from the SSD without being unduly hindered by its comparatively small capacity.

If you enjoyed this article, you may want to follow me (@mattgemmell) on Twitter, where I always announce new articles and projects. You may also want to read my biography, or hire me for your iPad, iPhone or Mac OS X app projects.

Using OS X with an SSD plus HDD setup

Solid-state drives (SSDs) are becoming commonplace, and the first time you use one as a boot drive, you realise why – they’re faster than hard drives to a ridiculous degree. The downside is they’re currently still very expensive compared to hard drives, such that only smaller capacities are currently affordable. Macs are now being offered with what I call “mixed drive” configurations, including both a (small; often 256 GB) SSD and an HDD, and many people wonder how to make the most of this setup.

I have two SSD-equipped machines here, including a mixed-drive iMac, and have recently configured it in what I believe is a good compromise setup to take advantage of SSD speed without sacrificing the roomy storage of a hard drive (or causing excessive wear to the SSD). This is just one possible setup, but I hope it’s useful to you.

The basic approach here is to have the OS on the SSD (the default setup on mixed-drive Macs), and to move certain folders onto the hard drive, providing links to those folders in the places they used to be. Before beginning, let me try to pre-empt two possible comments:

“You can tell iTunes (etc) to keep its data elsewhere!”

Indeed you can (usually by holding the alt/option key whilst launching the app), but you’ll have to do it for each and every app that has such a capability – and some apps won’t let you. The method I’m about to describe, however, will just work, without changing any settings.

“You can put the home folder on the hard drive, and use the Accounts pane to point to it!”

That’s also true (unlock the Accounts pane, then right-click on your account in the list), but you’re losing the speed benefit of having certain parts of your home folder on the SSD (such as caches, preferences, your development projects and so forth).

It’s your choice if you want to use one of the above limited expedients, but I feel that you can find a better balance by doing just a little bit of extra work.

Copying and Linking folders on the HDD

With that all said, let’s offload some folders to the hard drive. It’s extremely easy to do, even though there’s a tiny, tiny bit of typing on the Terminal involved. If you’re scared of that, by all means run away now and get a friend to help. Also, make sure you have an up-to-date backup of your boot drive before beginning; that’s just common sense.

We’re really just going to be repeating the same process over and over, once for each folder that you want to live on the HDD instead of the SDD. The process is simply this:

  1. In the Finder, copy the folder from the SSD to the HDD. Check that it was copied successfully.
  2. In Terminal, cd to the location of the original folder (on the SSD), and delete it via sudo rm -rf foldername.
  3. In Terminal, still in the location of the original folder you just deleted, make a link to the copy of the folder on the HDD, via ln -s /Volumes/HDDname/path/to/foldername.

(In steps 2 and 3 above, you should of course substitute the actual names and paths of the relevant folders and volume instead of ‘foldername’, ‘HDDname’, and ‘path/to/foldername’. Hopefully that’s obvious. For the ln command, think of the syntax as being “put a link here, that points to there“.)

That’s it. You’ll probably want to put all these copied folders somewhere sensible on the HDD; I created a folder called “matt” at the root of the HDD, and copied my folders into there – you can see a picture of it below. I’ve heard that you should not create a “Users” folder at the root of a non-boot disk, however.

List of folders moved onto a hard drive, and linked from the solid state drive

You should also note that, if you’ve copied and linked one of the “special” folders in your home directory (such as Pictures), the new folder/link won’t have the special icon that the Finder usually provides. That’s normal, and completely harmless. You may also need to re-add the folder to the Finder’s sidebar.

There’s nothing else to it, except to decide which folders to actually offload.

Choosing which folders to put on the HDD

This is a personal decision, but generally you’ll want to offload folders that fit any of these criteria:

  1. Are very large. Your SSD is small, and it shouldn’t be bursting at the seams.
  2. Will change extremely often, particularly if they contain large files. SSDs are notably subject to wear, especially if they don’t support TRIM.
  3. Contain files which aren’t involved in performance-critical work.

Try to keep in mind that the HDD is perfectly good enough for almost everything, and that we’ve been using HDDs for years. It’s not the poor cousin, and it hasn’t suddenly acquired the performance characteristics of a floppy disk drive. This is just about balance, and sensible optimisations to help get the most from the new SSD.

In my own case, I offloaded several of the folders in my home directory onto the HDD, as shown in the screenshot below.

List of folders in home folder on solid state drive, showing the following ones as links to the hard drive: Backups, Downloads, Dropbox, Movies and Pictures.

Note that the Dropbox folder is created by the utility of the same name, and that the Backups folder is one I created for my own use.

In addition to those, as shown in the picture, I offloaded Downloads, Movies and Pictures. I don’t keep things permanently in my Downloads folder yet its contents change constantly, so it was an excellent candidate for offloading. I also don’t heavily use iPhoto or Aperture, and keep my graphic work files in my Documents folder, so I could offload Pictures. I don’t do any video editing, and have a large Movies folder, so I offloaded it too.

I did not offload the Music folder, but I did offload the actual media files (and mobile apps) that iTunes uses, as shown in the picture of my Music folder’s contents below.

Contents of the Music folder, showing that the 'iTunes Music' folder (sometimes also called 'iTunes Media') within the iTunes folder is a link to a folder on the hard drive

Note that on your Mac, the “iTunes Music” folder may instead be called “iTunes Media”. The reason I didn’t offload the entire Music folder was to keep my GarageBand files on the SSD for performance, and nor did I offload the entire parent iTunes folder so that I could keep iTunes’ library and metadata files on the SSD for the same reason.

You may find that you’ll want to keep some of those folders on the SSD, and equally you may find that you want to offload additional folders to the HDD. For example, I also put my Virtual Machines folder on the HDD, and you might also want to put your Steam games there (they live in ~/Library/Application Support/Steam).

Just follow the same process as above, and you should be fine. It takes only a few minutes, and it should ensure that you get the maximum benefit from the SSD without being unduly hindered by its comparatively small capacity.

If you enjoyed this article, you may want to follow me (@mattgemmell) on Twitter, where I always announce new articles and projects. You may also want to read my biography, or hire me for your iPad, iPhone or Mac OS X app projects.