I have recently completed my first for fun app in xcode (using 3.1.2). The application is a countdown to my birthday and everything seems to work. I have tried running the app in Instruments to make sure there is no leaks or anything else wrong with it.
Running the app in Instruments shows me there are no leaks in the app, however, when looking at ObjectAlloc, I am a little confused on what is going on. When the app launches, Net Bytes, # Net and Overall Bytes continue to rise. It might be that I am not releasing certain things that I should, but I am not sure what I am doing wrong.
Here is the code for the project. Can anyone please help me?
AppDelegate.h
#import <UIKit/UIKit.h>
@class _010ViewController;
@interface _010AppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
_010ViewController *viewController;
NSTimer *timer;
}
-(void)goTime;
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet _010ViewController *viewController;
@end
AppDelegate.m
#import "_010AppDelegate.h"
#import "_010ViewController.h"
@implementation _010AppDelegate
@synthesize window;
@synthesize viewController;
- (void)applicationDidFinishLaunching

UIApplication *)application {
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO];
timer = [NSTimer scheduledTimerWithTimeInterval

1.0) target:self
selector:@selector(goTime) userInfo:nil repeats:YES];
[window addSubview:viewController.view];
[window makeKeyAndVisible];
}
- (void)goTime {
[viewController updateL];
}
- (void)dealloc {
[timer release];
[viewController release];
[window release];
[super dealloc];
}
@end
ViewContrller.m
#import "_010ViewController.h"
@implementation _010ViewController
- (void)viewDidLoad {
//sets up the fond and the labels for the text to be displayed
[counterL setFont:[UIFont fontWithName:@"Zapfino" size:20]];
[counterB setFont:[UIFont fontWithName:@"Zapfino" size:20]];
counterL.textColor = [UIColor whiteColor];
counterB.textColor = [UIColor whiteColor];
counterL.text = @"D";
counterB.text = @"A";
[super viewDidLoad];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
- (void)dealloc {
[counterL release];
[counterB release];
[super dealloc];
}
- (void)updateL {
NSCalendar *calendar= [[[NSCalendar alloc]
initWithCalendarIdentifier:NSGregorianCalendar] autorelease];
NSCalendarUnit unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit
| NSDayCalendarUnit | NSHourCalendarUnit |
NSMinuteCalendarUnit | NSSecondCalendarUnit;
NSDate *date = [NSDate date];
NSDateComponents *dateComponents = [calendar
components:unitFlags fromDate:date];
int year = [dateComponents year];
int month = [dateComponents month];
int day = [dateComponents day];
int hour = [dateComponents hour];
int minute = [dateComponents minute];
int second = [dateComponents second];
/* Do Stuff here with those ints to calculate the time remaining and
change the labels based on them
@end
ViewController.h
#import <UIKit/UIKit.h>
@interface _010ViewController : UIViewController {
IBOutlet UILabel *counterL;
IBOutlet UILabel *counterB;
}
-(void)updateL;
@end