Skip to content

Instantly share code, notes, and snippets.

@okaram
Last active December 10, 2015 08:58
Show Gist options
  • Save okaram/4410700 to your computer and use it in GitHub Desktop.
Save okaram/4410700 to your computer and use it in GitHub Desktop.
iOS first App - Temperature conversion
-(IBAction) convertToCelsius:(id)sender
{
int f=[self.fahrenheit.text intValue];
int c=[self faren2celsius:f];
self.celsius.text=[NSString stringWithFormat:@"%d",c];
}
-(float)faren2celsius:(int) faren
{
return (faren-32)/1.8;
}
#import <UIKit/UIKit.h>
@interface TempViewController : UIViewController
@property(weak,nonatomic) IBOutlet UITextField* fahrenheit;
@property(weak,nonatomic) IBOutlet UILabel* celsius;
-(IBAction) convertToCelsius:(id)sender;
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment