This is all the code.... I was following the tutorial found here:
http://appsamuck.com/day1.html
Thanks, I'm a newbie top the Mac world.
// MinutesToMidnightViewController.m
// MinutesToMidnight
#import "MinutesToMidnightViewController.h"
@implementation MinutesToMidnightViewController
-(void)viewDidLoad {
[countdownLabel setFont:[UIFont fontWithName:@"DS-Digital" size:64.0]];
countdownLabel.text = @"I0A0IN6";
[super viewDidLoad];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceO rientation {
// 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)dealloc {
[super dealloc];
}
-(void)updateLabel {
NSDate* now = [NSDate date];
int hour = 23 - (int)[[now dateWithCalendarFormat:nil timeZone:nil] hourOfDay];
int min = 59 - (int)[[now dateWithCalendarFormat:nil timeZone:nil] minuteOfHour];
int sec = 59 - (int)[[now dateWithCalendarFormat:nil timeZone:nil] secondOfMinute];
countdownLabel.text = [NSString stringWithFormat:@"%02d:%02d:%02d", hour, min,sec];
}
@end
------
// MinutesToMidnightViewController.h
#import <UIKit/UIKit.h>
@interface MinutesToMidnightViewController : UIViewController {
IBOutlet UILabel *countdownLabel;
}
-(void)updateLabel;
@end
-----
// MinutesToMidnightAppDelegate.m
#import "MinutesToMidnightAppDelegate.h"
#import "MinutesToMidnightViewController.h"
@implementation MinutesToMidnightAppDelegate
@synthesize window;
@synthesize viewController;
- (void)applicationDidFinishLaunching:(UIApplication *)application {
timer = [NSTimer scheduledTimerWithTimeInterval:(1.0) target:self selector:@selector(onTimer) userInfo:nil repeats:YES];
[window addSubview:viewController.view];
[window makeKeyAndVisible];
}
- (void)onTimer {
[viewController updateLabel];
}
- (void)applicationWillTerminate:(UIApplication *)application {
[timer invalidate];
}
- (void)dealloc {
[timer release];
[viewController release];
[window release];
[super dealloc];
}
@end
-----
// MinutesToMidnightAppDelegate.h
#import <UIKit/UIKit.h>
@class MinutesToMidnightViewController;
@interface MinutesToMidnightAppDelegate : NSObject <UIApplicationDelegate> {
IBOutlet UIWindow *window;
IBOutlet MinutesToMidnightViewController *viewController;
NSTimer *timer;
}
-(void)onTimer;
@property (nonatomic, retain) UIWindow *window;
@property (nonatomic, retain) MinutesToMidnightViewController *viewController;
@end