Skip to content

Instantly share code, notes, and snippets.

@projectxcappe
Created July 13, 2011 15:18
Show Gist options
  • Save projectxcappe/1080502 to your computer and use it in GitHub Desktop.
Save projectxcappe/1080502 to your computer and use it in GitHub Desktop.
viewcontroller.h
//
// Wasted_SpaceViewController.h
// Wasted Space
//
// Created by Cassidy Pangell on 7/12/11.
// Copyright 2011 Circadence. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface Wasted_SpaceViewController : UIViewController {
IBOutlet UILabel *time;
NSTimer *myTicker;
UIButton *fourty;
UIButton *sixty;
UIButton *eighty;
UIButton *ghundred;
UIButton *hundred;
UIButton *delFourty;
UIButton *delSixty;
UIButton *delEighty;
UIButton *delGHundred;
UIButton *delHundred;
IBOutlet UILabel *t_fourty;
IBOutlet UILabel *t_sixty;
IBOutlet UILabel *t_eighty;
IBOutlet UILabel *t_ghundred;
IBOutlet UILabel *t_hundred;
IBOutlet UILabel *total;
}
-(IBAction)start;
-(IBAction)stop;
-(IBAction)reset;
-(IBAction)mFourty;
-(IBAction)mSixty;
-(IBAction)mEighty;
-(IBAction)mGHundred;
-(IBAction)mHundred;
-(IBAction)dFourty;
-(IBAction)dSixty;
-(IBAction)dEighty;
-(IBAction)dGHundred;
-(IBAction)dHundred;
-(void)showActivity;
-(void)update;
@end
//
// Wasted_SpaceViewController.m
// Wasted Space
//
// Created by Cassidy Pangell on 7/12/11.
// Copyright 2011 Circadence. All rights reserved.
//
#import "Wasted_SpaceViewController.h"
@implementation Wasted_SpaceViewController
-(IBAction)start{
myTicker = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(showActivity) userInfo:nil repeats:YES];
}
-(IBAction)stop{
[myTicker invalidate];
}
-(IBAction)reset{
time.text = @"0";
}
-(void)showActivity{
int currentTime = [time.text intValue];
int newTime = currentTime + 1;
time.text = [NSString stringWithFormat:@"%d", newTime];
}
-(void)update{
int fourtyVal = [t_fourty.text intValue];
int newFourty = fourtyVal * 40000;
int sixtyVal = [t_sixty.text intValue];
int newSixty = sixtyVal * 55000;
int eightyVal = [t_eighty.text intValue];
int newEighty = eightyVal * 75000;
int hundredVal = [t_hundred.text intValue];
int newHundred = hundredVal * 95000;
int ghundredVal = [t_ghundred.text intValue];
int newGHundred = ghundredVal * 105000;
int sum = newFourty + newSixty + newEighty + newHundred + newGHundred;
total.text = [NSString stringWithFormat:@"%d", sum];
}
-(IBAction)mFourty{
int tVal = [t_fourty.text intValue];
int newVal = tVal + 1;
t_fourty.text = [NSString stringWithFormat:@"%d", newVal];
update();
}
-(IBAction)mSixty{
int tVal = [t_sixty.text intValue];
int newVal = tVal + 1;
t_sixty.text = [NSString stringWithFormat:@"%d", newVal];
update();
}
-(IBAction)mEighty{
int tVal = [t_eighty.text intValue];
int newVal = tVal + 1;
t_eighty.text = [NSString stringWithFormat:@"%d", newVal];
update();
}
-(IBAction)mGHundred{
int tVal = [t_ghundred.text intValue];
int newVal = tVal + 1;
t_ghundred.text = [NSString stringWithFormat:@"%d", newVal];
update();
}
-(IBAction)mHundred{
int tVal = [t_hundred.text intValue];
int newVal = tVal + 1;
t_hundred.text = [NSString stringWithFormat:@"%d", newVal];
update();
}
-(IBAction)dFourty{
int tVal = [t_fourty.text intValue];
int newVal = tVal - 1;
if(newVal < 0){
newVal = 0;
}
t_fourty.text = [NSString stringWithFormat:@"%d", newVal];
update();
}
-(IBAction)dSixty{
int tVal = [t_sixty.text intValue];
int newVal = tVal - 1;
if(newVal < 0){
newVal = 0;
}
t_sixty.text = [NSString stringWithFormat:@"%d", newVal];
update();
}
-(IBAction)dEighty{
int tVal = [t_eighty.text intValue];
int newVal = tVal - 1;
if(newVal < 0){
newVal = 0;
}
t_eighty.text = [NSString stringWithFormat:@"%d", newVal];
update();
}
-(IBAction)dGHundred{
int tVal = [t_ghundred.text intValue];
int newVal = tVal - 1;
if(newVal < 0){
newVal = 0;
}
t_ghundred.text = [NSString stringWithFormat:@"%d", newVal];
update();
}
-(IBAction)dHundred{
int tVal = [t_hundred.text intValue];
int newVal = tVal - 1;
if(newVal < 0){
newVal = 0;
}
t_hundred.text = [NSString stringWithFormat:@"%d", newVal];
update();
}
/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
*/
/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/
/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
}
*/
/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/
- (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.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[super dealloc];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment