Skip to content

Commit

Permalink
Fixed several memory leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian Schoenig committed Feb 13, 2009
1 parent c32e39a commit a9a296a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 24 deletions.
5 changes: 4 additions & 1 deletion iphone/Classes/Device.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
#import <UIKit/UIDevice.h>

@interface Device : NSObject {
NSString *jsCallBack;
UIDevice *myCurrentDevice;
}

- (Device *) init;
- (NSString *)getDeviceInfo;
- (void) dealloc;

@end
36 changes: 19 additions & 17 deletions iphone/Classes/Device.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,28 @@

@implementation Device

- (NSString *)init{

jsCallBack = nil;
myCurrentDevice = [UIDevice currentDevice];

return jsCallBack = [[NSString alloc] initWithFormat:@"\
__gap = true; \
__gap_version='0.1'; \
__gap_device_model='%s'; \
__gap_device_version='%s';\
__gap_device_uniqueid='%s';",
[[myCurrentDevice model] UTF8String],
[[myCurrentDevice systemVersion] UTF8String],
[[myCurrentDevice uniqueIdentifier] UTF8String]
];
- (Device *)init {
if (self = [super init]) {
myCurrentDevice = [UIDevice currentDevice];
}
return self;
}

- (NSString *)getDeviceInfo {
return [NSString stringWithFormat:@"\
__gap = true; \
__gap_version='0.1'; \
__gap_device_model='%s'; \
__gap_device_version='%s';\
__gap_device_uniqueid='%s';",
[[myCurrentDevice model] UTF8String],
[[myCurrentDevice systemVersion] UTF8String],
[[myCurrentDevice uniqueIdentifier] UTF8String]
];
}

- (void)dealloc {
[jsCallBack release];
[myCurrentDevice release];
[myCurrentDevice release];
[super dealloc];
}

Expand Down
16 changes: 10 additions & 6 deletions iphone/Classes/GlassAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ - (void)applicationDidFinishLaunching:(UIApplication *)application {
webView.detectsPhoneNumbers=detectNumber;

//This keeps the Default.png up
imageView = [[UIImageView alloc] initWithImage:[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Default" ofType:@"png"]]];
UIImage * tempImage = [[[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Default" ofType:@"png"]] autorelease];
imageView = [[UIImageView alloc] initWithImage:tempImage];
[window addSubview:imageView];

activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
[window addSubview:activityView];
[activityView startAnimating];
[window makeKeyAndVisible];


//NSBundle * mainBundle = [NSBundle mainBundle];

Expand All @@ -99,7 +99,9 @@ - (void)applicationDidFinishLaunching:(UIApplication *)application {

//when web application loads pass it device information
- (void)webViewDidStartLoad:(UIWebView *)theWebView {
[theWebView stringByEvaluatingJavaScriptFromString:[[Device alloc] init]];
Device * device = [[Device alloc] init];
[theWebView stringByEvaluatingJavaScriptFromString:[device getDeviceInfo]];
[device release];
}

- (void)webViewDidFinishLoad:(UIWebView *)theWebView {
Expand Down Expand Up @@ -195,9 +197,7 @@ - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLoca


- (void) accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration {
NSString * jsCallBack = nil;

jsCallBack = [[NSString alloc] initWithFormat:@"gotAcceleration('%f','%f','%f');", acceleration.x, acceleration.y, acceleration.z];
NSString * jsCallBack = [NSString stringWithFormat:@"gotAcceleration('%f','%f','%f');", acceleration.x, acceleration.y, acceleration.z];
[webView stringByEvaluatingJavaScriptFromString:jsCallBack];
}

Expand Down Expand Up @@ -248,6 +248,9 @@ - (void)imagePickerController:(UIImagePickerController *)picker didFinishPicking

webView.hidden = NO;
[window bringSubviewToFront:webView];

[request release];
[conn release];
}


Expand Down Expand Up @@ -299,6 +302,7 @@ - (void)dealloc {
[lastKnownLocation release];
[imagePickerController release];
[appURL release];
[sound release];
[super dealloc];
}

Expand Down

0 comments on commit a9a296a

Please sign in to comment.