//
// ViewController.m
// UnitConverterC
//
// Created by Apple7 on 2015. 9. 30..
// Copyright © 2015년 gsh. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)convertTemp:(id)sender {
double farenheit = [_tempText.text doubleValue];
double celsius = (farenheit - 32) / 1.8;
NSString *resultString = [[NSString alloc]
initWithFormat: @"Celsius %f", celsius];
_resultLabel.text = resultString;
}
- (IBAction)textFieldReturn:(id)sender {
[sender resignFirstResponder];
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
if ([_tempText isFirstResponder] && [touch view] != _tempText) {
[_tempText resignFirstResponder];
}
[super touchesBegan:touches withEvent:event];
}
@end
//
// ViewController.h
// UnitConverterC
//
// Created by Apple7 on 2015. 9. 30..
// Copyright © 2015년 gsh. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property (weak, nonatomic) IBOutlet UITextField *tempText;
@property (weak, nonatomic) IBOutlet UILabel *resultLabel;
- (IBAction)convertTemp:(id)sender;
- (IBAction)textFieldReturn:(id)sender;
@end